[thelist] How to tell if a regular expression is valid?

Jason Lustig jasonlustig at adelphia.net
Wed Jul 14 17:58:55 CDT 2004


So I'm working on a PHP script in which the user inputs a the search and 
replace sections of a regular expression in a form. For example, they 
might input "\[b\](.*?)\[\/b\]" (without the quotes) as the search 
section and "<b>\1</b>" as the replace part, and then the PHP script 
puts them together in the preg_replace() function.

The only thing is, I want the script to check to see if the regular 
expressions they put in are valid, i.e. if they will work. I've done 
some searching on a regular expression to test if regular expressions 
are valid or something like that. Any ideas?

Thanks!

Jason


More information about the thelist mailing list