When parsed to tokens, why are backslashes stripped from pattern?
Lord-Kamina opened this issue · comments
Gregorio Litenstein commented
When creating tokens out of a match, why does the lexer function skip \
inside patterns? (For example, turning \w+
into just w+
?
Douglas Wilson commented
It's not the lexer, it is javascript. See what the output is of console.log('\w+')
.
Tip: Backslashes need to be escaped with another backslash in JavaScript strings.
Gregorio Litenstein commented
It's not the lexer, it is javascript. See what the output is of
console.log('\w+')
.Tip: Backslashes need to be escaped with another backslash in JavaScript strings.
Ah, makes sense. I didn't account for that, as I got here from a C++ port, with which we generally use raw strings. :P
Thanks for the quick reply!