-
-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
In an attempt to catch additional characters while checking for case in the subject, I ran into a limitation where I need to pass the unicode flag to RegExp()
:
> const strings = ["information", "Information", "Ínformation", "ínformation"];
undefined
> const old = new RegExp("^(?![A-Z]).+$", "g");
undefined
> const new = new RegExp("^(?!\\p{Lu}).+$", "gu");
undefined
> strings.forEach((s) => { console.log(`${s}: ${old.test(s)}`) });
information: true
Information: false
Ínformation: true
ínformation: false
undefined
> strings.forEach((s) => { console.log(`${s}: ${new.test(s)}`) });
information: true
Information: false
Ínformation: false
ínformation: true
undefined
I see two paths here:
- Allow passing regex literal instead of a string to
RegExp()
- Allow users to set the
RegExp()
options (currently hardcoded tog
)
Which one is preferred? I can take a stab at a PR.
FelipeLema
Metadata
Metadata
Assignees
Labels
No labels