I’ve been grappling with some negative lookahead and lookbehind patterns to no avail. I need a regex that will match everything in a string before two forward slashes, unless said characters are in quotes.
For example, in the string "//this is a string//" //A comment about a string about strings,
the substring "//this is a string//" ought to be matched and the rest ignored.
As you can see, the point is to exclude any single-line comments (C++/Java style).
Thanks in advanced.
How about
It will match
//if it is not followed by either a"or a'. It’s not exactly what you requested, but closely meets your requirements. It will only choke on comments that contain"or', likeMaybe better than no solution.