I wanted to learn about regular expressions, so I decided to build a "regular expression" tool that would allow you to 'build' your expressions, test them, etc. 'The best way to learn is by teaching...or something like that, right?' 
The app is at:
I am now at the phase of handling sytnax errors, but the more code I write, the more I am seeing that the number of syntax error possibilities are staggering. For instance, if you visit the app and enter a ? as the first character of your expression, you will notice that I have trapped that particular error.
Does anyone know of any "rules of thumb" regarding reg exp syntax? Below is part of the syntax error checking - in this example I am checking for syntax errors related to the ? metacharacter:
// -------------------------------------------------------
// Syntax Error Check - ?
// -------------------------------------------------------
reSyntax = /([^\\].[$\+\*\^bB\|]\?)/gi;
arrSyntaxResult = re.match(reSyntax);
if(arrSyntaxResult){
retStr = "<b>The error <i>appears</i> to be located in the following group of characters, and related to the ?: " + arrSyntaxResult.toString() + "</b><p>";
retStr+=questionStr; // Just a help string
return retStr;
}
As you can see, I am only checking for invalid characters to the LEFT of the metacharacter ( while making sure that it is not escaped ).
IS THERE AN EASIER WAY TO DO THIS??????????????????????
Does Javascript's Reg Expressions have some sort of Error property that I can access??? ( fingers crossed! )
Thanks for any help offered!
Trope
The app is at:
I am now at the phase of handling sytnax errors, but the more code I write, the more I am seeing that the number of syntax error possibilities are staggering. For instance, if you visit the app and enter a ? as the first character of your expression, you will notice that I have trapped that particular error.
Does anyone know of any "rules of thumb" regarding reg exp syntax? Below is part of the syntax error checking - in this example I am checking for syntax errors related to the ? metacharacter:
// -------------------------------------------------------
// Syntax Error Check - ?
// -------------------------------------------------------
reSyntax = /([^\\].[$\+\*\^bB\|]\?)/gi;
arrSyntaxResult = re.match(reSyntax);
if(arrSyntaxResult){
retStr = "<b>The error <i>appears</i> to be located in the following group of characters, and related to the ?: " + arrSyntaxResult.toString() + "</b><p>";
retStr+=questionStr; // Just a help string
return retStr;
}
As you can see, I am only checking for invalid characters to the LEFT of the metacharacter ( while making sure that it is not escaped ).
IS THERE AN EASIER WAY TO DO THIS??????????????????????
Does Javascript's Reg Expressions have some sort of Error property that I can access??? ( fingers crossed! )
Thanks for any help offered!
Trope