Page 1 of 1

preg_match_all

Posted: Tue Mar 08, 2011 9:59 am
by agriz
Hi,

What is the difference between these two calls?

Code: Select all

$pattern = "/something here/";
$pattern = "|something here|";

Re: preg_match_all

Posted: Tue Mar 08, 2011 10:04 am
by Kadanis
Nothing really. PHP allows for any symbol (as far as I am aware) to be used as the limiters in regular expressions.

Personally I tend to always use / as it is generally the standard in other languages. Some people will use other characters as the limiters if they are going to be using the / in the regular expression itself so that it doesn't have to be escaped.

Basically, if you use a particular character as the limiter of the expression, you will have to escape that character if it is used in the expression.

I've seen # and @ used in code before.

Re: preg_match_all

Posted: Wed Mar 09, 2011 10:24 am
by agriz
Thanks