bmroberts1987 / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

Error in matching string litterals, plus fix #122

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. When trying to view the source of its own code:
 SingleQuotedString : new RegExp("'(?:\\.|(\\ \\ \\')|[^\\''\\n])*'", 'g')
will hilight incorrectly 

What is the expected output? What do you see instead?
The 'g' isn't highlighted in this line.  This is because the regexes are
overlapping.  You really want to start scanning again after the point where
another string has ended.  This is a case where a single quote appears in a
double quoted string and then again later in the line.  

What version of the product are you using? On what operating system?
1.5.2, Mac OSX.  Bug reproducible in Firefox 3 and Safari.

Please provide any additional information below.
You can merge both of the Single and Double quoted strings with the
following regex:
/(['"])(\\.|[^\1])*?\1/g
This way, it finds the whole string literal before matching another.  

Original issue reported on code.google.com by nathanwi...@gmail.com on 20 Nov 2008 at 4:30