What are the valid delimiters for preg_ regular expressions?

2

What are the valid delimiters for regular expressions preg_* ?

I know we can use some of these ( / , ~ and # ), as I show in the example below:

$numero = '0.12.13';
preg_replace('/\D+/', '', $numero); // string('01213')
preg_replace('~\D+~', '', $numero); // string('01213')
preg_replace('#\D+#', '', $numero); // string('01213')

But I would like to know the other regular expression delimiters (from PREG ) in PHP.

Can I use only special characters (and never numbers or letters)?

If yes, what are these special characters?

    
asked by anonymous 28.08.2015 / 14:13

1 answer

3

From link :

  

A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.

(free translation)

A delimiter can be any non-alphanumeric character, not backslash, not whitespace.

The ones you used in the example are the most common ones. There are many options for valid delimiters (including those with special function in the regular expression): . , $ , _ , : , ? , ^ , % / p>

Demo: link

    
28.08.2015 / 14:24