Page 1 of 1

preg_match_all reg expression trouble

Posted: Sat Jun 08, 2002 7:43 am
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

Posted: Sat Jun 08, 2002 8:15 am
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