Invalid regular expression during compilation for a known valid regular expressionοΏ½?#54081
Closed
Description
Bug Report
π Search Terms
regex, RegExp
π Version & Regression Information
- This is the behavior in every version I tried.
β― Playground Link
Playground link with relevant code
π» Code
const REGEX_PATTERN_2: RegExp = new RegExp(`(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+`, "g");
const str = "This is a TopGame";
let match;
while ((match = REGEX_PATTERN_2.exec(str)) !== null) {
console.log(`Match found at position ${match.index}.`);
console.log(`Matched string: ${match[0]}.`);
}π Actual behavior
SyntaxError: Invalid regular expression: /(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]|\s[\r\n]+|\s+(?!\S)|\s+/: Invalid group
π Expected behavior
The regular expression should be compiled properly.
Activity