Restricting JavaScript regular expressions to single line

Neil <[email protected]> Sun, 26 Jul 2026 19:03:10 -0700 (PDT)
Newsgroups gmane.comp.lib.scintilla.devel
Message-ID <[email protected]>
------=_Part_450676_1477988985.1785117790049
Content-Type: multipart/alternative; 
	boundary="----=_Part_450677_1174112145.1785117790049"

------=_Part_450677_1174112145.1785117790049
Content-Type: text/plain; charset="UTF-8"

The hypertext (HTML), xml, and cpp lexers recognize regular expression 
literals in JavaScript. These start and end with '/' so may appear like this

"x 100".match(/\d+/)

'/' is also used for division so there is some code to choose between the 
'/' being an operator or the start of a regular expression literal. The 
implementation is not always accurate. It examines previous text for 
various characters that imply the likelihood of one choice. The regular 
expression literal terminates after another '/' but it also terminates at 
the end of the line.

This implies that a regular expression literal can not continue onto 
subsequent lines. I have not found a definitive statement that this is the 
case but searching for related terms on the web did not produce 
contradicting evidence.

Therefore, it may improve the lexers to only transition to regex literal 
style when the initiating '/' is followed by at least one more '/' on the 
same line.

Neil

-- 
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/acd94e93-8e64-41d4-aa04-a388657631fcn%40googlegroups.com.

------=_Part_450677_1174112145.1785117790049
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

The hypertext (HTML), xml, and cpp lexers recognize regular expression lite=
rals in JavaScript. These start and end with '/' so may appear like this<di=
v><br /><div>"x 100".match(/\d+/)</div></div><div><br /></div><div>'/' is a=
lso used for division so there is some code to choose between the '/' being=
 an operator or the start of a regular expression literal. The implementati=
on is not always accurate. It examines previous text for various characters=
 that imply the likelihood of one choice. The regular expression literal te=
rminates after another '/' but it also terminates at the end of the line.</=
div><div><br /></div><div>This implies that a regular expression=C2=A0liter=
al can not continue onto subsequent lines. I have not found a definitive st=
atement that this is the case but searching for related terms on the web di=
d not produce contradicting evidence.</div><div><br /></div><div>Therefore,=
 it may improve the lexers to only transition to regex literal style when t=
he initiating '/' is followed by at least one more '/' on the same line.</d=
iv><div><br /></div><div>Neil</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scintilla-interest&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
scintilla-interest/acd94e93-8e64-41d4-aa04-a388657631fcn%40googlegroups.com=
?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/=
scintilla-interest/acd94e93-8e64-41d4-aa04-a388657631fcn%40googlegroups.com=
</a>.<br />

------=_Part_450677_1174112145.1785117790049--

------=_Part_450676_1477988985.1785117790049--