preg_match_all reg expression trouble

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
Robert
Forum Newbie
Posts: 3
Joined: Sat Jun 08, 2002 7:43 am
Contact:

preg_match_all reg expression trouble

Post by Robert »

I can't seem to get what the regular expression would be to use preg_match_all.

It works to with ereg, but someone kindly pointed out to get all instances on a page I would need to use preg_match_all.

Can someone please steer me in the right direction with this? Here's the expression

preg_match_all ("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}", 122.994.098.232122.222.098.232122.234.033.232, $out,PREG_PATTERN_ORDER);

Warning: Unknown modifier '{'
If I take out all the (1,3} I get:
Warning: Unknown modifier '.'

I know that it was valid with ereg. Why won't it work with this? Any help would be greatly appreciated.

Robert
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

preg_ uses delimeter that you can choose freely i.e.
preg_match_all('/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/', '122.994.098.232122.222.098.232122.234.033.232', $out,PREG_PATTERN_ORDER);
or
preg_match_all('![0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}!', ...
should work
Post Reply