This is a corner case when constructing RegExps from strings, line terminator characters preceded by a backslash appear to have a distinct behavior that I couldn't see reflected in the spec:
console.log([
new RegExp('\n').source === new RegExp('\\\n').source,
// true
new RegExp('\t').source === new RegExp('\\\t').source,
// false
], [
new RegExp('\x0a').source === new RegExp('\\\x0a').source,
// true
new RegExp('\x03').source === new RegExp('\\\x03').source,
// false
], [
new RegExp('\u2028').source === new RegExp('\\\u2028').source,
// true
new RegExp('\u2018').source === new RegExp('\\\u2018').source,
// false
])
Is it a browser quirk or a spec bug? The three-backslash variants are rejected when the 'u'
flag is used.