Closed InSyncWithFoo closed 11 months ago
Based on the updated proposal, ("\d \D (?:)"
should escape to \(\"\\d\ \\D\ \(\?\:\)"
, if I'm following the algorithm correctly.
@ljharb the problem is that the string "\d \D (?:)"
is the same as the string "d D (?:)"
. i.e. "\d \D (?:)" === "d D (?:)"
.
If you want to have a string with backslashes in, you need to either escape the backslashes or use String.raw
.
ahhhh gotcha. meaning that the text content \d \D (?:)
is the string d D (?:)
which should then escape to the string d\ D\ \(\?\:\)
I'll update the readme to correct this, thanks.
I'm talking about this one:
The string
"\d \D (?:)"
has 8 characters and no backslashes. Isn't this supposed to be either"\\d \\D (?:)"
orString.raw`\d \D (?:)`
?Perhaps other examples can also use some help in this manner:
I agree, multiple backslashes are indeed horrible, so something like this would also suffice:
But again, maybe I'm just being too pedantic.