Page 1 of 1

ereg not working with wildcards?

Posted: Mon Jul 11, 2005 11:31 am
by IceMetalPunk
This is really strange... ereg is supposed to be able to find a match of a regular expression inside a string, right? And wildcards can be used in regular expressions as *, right? So how come when I do this:

Code: Select all

ereg("*hello*",$mystring,$mymatches);
It always gives this error:

Warning: ereg(): REG_BADRPT:.repetition-operator operand invalid??

-IMP ;) :)

Posted: Mon Jul 11, 2005 11:46 am
by Burrito
umm not quite. regex doesn't take a "wildcard" like that.

I suggest you read the crash course that d11 put up. It's a fantastic guide for learning and using regex.

viewtopic.php?t=33147

Posted: Mon Jul 11, 2005 11:46 am
by timvw

Code: Select all

ereg("#hello#",$mystring,$mymatches);
ereg("/hello/",$mystring,$mymatches);