ereg not working with wildcards?

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
User avatar
IceMetalPunk
Forum Commoner
Posts: 71
Joined: Thu Jul 07, 2005 11:45 am

ereg not working with wildcards?

Post 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 ;) :)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Code: Select all

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