Skip to content

Treat the default regular expression syntax as being with the Unicode flag #958

Closed
@brettz9

Description

@brettz9

From #821 (apologies for commenting further there, as I had interpreted the issue as a general choice for the interpretation of the existing regular expression rule)

Though #32 seeks to add the ability to use flags, in order to ensure plain regular expressions are looking forward to future usage, I think, if feasible, and if not too late, it would be ideal to see the u flag enforced by default, including with property escapes.

There are a few reasons in my view:

  1. Besides offering new features, working with full code points, etc., certain syntax allowable without the flag will become no longer allowable, i.e., an unescaped { literal.
  2. The JavaScript community has mechanisms already for preferring the flag: https://eslint.org/docs/rules/require-unicode-regexp
  3. There is a massive amount of expressivity in regular expressions with the u flag (e.g., Unicode properties such as any Unicode letter with \p{Letter})

Some potential factors against:

  1. Level of adoption is not universal. https://caniuse.com/#search=unicode%20regex lists global adoption of the Unicode flag at 91.54% globally and the separate support for the powerful Unicode Property escapes support at 84.89%
  2. It might be seen as suggestive that without a flag mechanism, the default from JavaScript would be used--i.e., no flags, and therefore no Unicode flag.

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