TNO
01-16-2009, 02:30 PM
I've been trying to figure out how to write a regular expression to match a regular expression literal, but am having issues with false positives. Here's what I have currently:
/^(?:\/((?:\\.|\[(?:\\.|[^\]])*\]|[^\/])+)\/([gimy]*))/i
and here is an example of a string it gives a false positive on:
/ 2;
//comment
var b = /\n/g;
Any thoughts on what I may be doing wrong with this regular expression?
(FYI: The leading portions of the input string are removed as matches are found, which is why the division operator is now the first character in the input string).
As always, any insight is appreciated
/^(?:\/((?:\\.|\[(?:\\.|[^\]])*\]|[^\/])+)\/([gimy]*))/i
and here is an example of a string it gives a false positive on:
/ 2;
//comment
var b = /\n/g;
Any thoughts on what I may be doing wrong with this regular expression?
(FYI: The leading portions of the input string are removed as matches are found, which is why the division operator is now the first character in the input string).
As always, any insight is appreciated