Page 1 of 1

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

Posted: Mon Jan 02, 2006 3:52 am
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?

Posted: Mon Jan 02, 2006 4:00 am
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.

Posted: Mon Jan 02, 2006 4:03 am
by IAD
Cause i always forgot how to use preg_match's delimeters, like chines for me :P [/sd]/\thanks//\[ds+] :P

Posted: Mon Jan 02, 2006 9:09 am
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)

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

Posted: Mon Jan 02, 2006 1:17 pm
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.