Skip to content

Regexp does not support empty character classes. #832

@RunDevelopment

Description

@RunDevelopment

TS and JS Grammar Extension version: 0.0.53 / latest

Description

Empty character classes, while not very useful, are valid JS/TS and should be supported. This issue is especially noticeable while writing regexes because highlighting breaks whenever you add a new character class.

Code

let a = /foo[]bar/;
let b = /foo[^]bar/;

Will be highlighted as:

image

Fix

The pattern for character classes is \[([^\]\\]|\\.)+\], right now. Simply changing it to \[([^\]\\]|\\.)*\] (uses * not +) should fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions