Skip to content

Support astral \u{...} outside of character classes without native /u #110

Open
@slevithan

Description

@slevithan

XRegExp 3.0.0 introduced support for ES6's \u{...} syntax in all browsers, but requires native flag u if this syntax is used for astral code points--i.e. above \u{FFFF}. However, it would not require much work to support astral \u{...} outside of character classes using surrogate pairs. You'd simply need to generate the surrogate pair and wrap it with (?: ). The wrapping would allow it to work as expected with following quantifiers.

Unfortunately, an error would still need to be thrown if astral \u{...} is used within character classes and the regex does not use native u.

Con: Syntax that works only outside of character classes has potential to cause confusion or frustration.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions