Re: validating ereg patterns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux