tunhien
asked on
How to check a regular expression string is valid or not?
I try to write a program that allow people to input an regular expression and then I will use it to excute. But If the input string is not a valide regular expression then when execute it, the executer will through error.
It's not good. And I wanna check the valide of it!
So please show me how to do that!
Thanks so much!
It's not good. And I wanna check the valide of it!
So please show me how to do that!
Thanks so much!
Maybe there is an easier way.... try using a "try .. catch..." block when you create the regex object:
try {
var re = new RegExp(document.yourFormNa
}
catch {
alert("that's some funky regex dude.");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe this guy can inpire you:
http://osteele.com/tools/rework/
http://osteele.com/tools/rework/reparse.js