preg_match_all

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

preg_match_all

Post by agriz »

Hi,

What is the difference between these two calls?

Code: Select all

$pattern = "/something here/";
$pattern = "|something here|";
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Re: preg_match_all

Post 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.
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: preg_match_all

Post by agriz »

Thanks
Post Reply