Why can't i use ? in eregi()?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Why can't i use ? in eregi()?

Post by IAD »

Hey,

when i try to use question mark in eregi() it gives me:


Warning: eregi() [function.eregi]: REG_BADRPT in c:\myfiles\pagemaker\basefiles\classes.php on line 268

what is the problem?
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

whats the exact regex you used?

why not use preg_match? its faster and you can use the i pattern delimiter to make the search case insensitive.
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

Cause i always forgot how to use preg_match's delimeters, like chines for me :P [/sd]/\thanks//\[ds+] :P
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to regex.

Could you post the regular expression you're using please? :) As far as I know the ? should work in ereg (POSIX).

Perl-style regular expressions do make things a lot simpler though.... preg_match('/pattern/i', $string)
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Re: Why can't i use ? in eregi()?

Post by sweatje »

IAD wrote:Hey,

when i try to use question mark in eregi() it gives me:


Warning: eregi() [function.eregi]: REG_BADRPT in c:\myfiles\pagemaker\basefiles\classes.php on line 268

what is the problem?
You have not really provided all the information needed to make a good response, but I suspect your issue is that ? has a meaning for regex, it makes the preceding token option (zero or one allowed). If what preceedes it is not a valid token, then you would have a bad regex. You probably just want to escape it with a \.

This all assumes you are actually trying to match the character ? as a part of your regex.

HTH.
Post Reply