Re: validating ereg patterns

From: Date: Wed, 29 Mar 2006 16:26:13 +0000
Subject: Re: validating ereg patterns
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-232836@lists.php.net to get a copy of this message
How do I detect the difference between a bad ereg pattern and no matches? I've got a UI that allows the user to enter an ereg expression. Clearly, the user may enter an invalid expression (for example, the expression may not have matching [] brackets). ereg returns false if there are no matches or if an error occurred. I need to distinguish between no matches and an error, so I can present a meaningful message to the user. Any suggestions on how to do this?
Maybe try preg_match. The docs say it will return false for an error, otherwise the number of times it matched. -philip

« previous php.general (#232836) next »