Skip to content

Invalid regular expression during compilation for a known valid regular expressionοΏ½?#54081

Closed
@shengyfu

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions