The provided string is javascript RegExp or not
Is there any kind of method that will check the provided string is javascript RegExp format or not?
The provided string is javascript RegExp or not
Is there any kind of method that will check the provided string is javascript RegExp format or not?
You can try below code
var isRegExp = true;
try {
new RegExp("regexphere");
} catch(e) {
isRegExp = false;
}
if(!isRegExp) alert("Not a valid regular expression");