25 lines
716 B
Plaintext
25 lines
716 B
Plaintext
== Why is this an issue?
|
|
|
|
JavaScript regular expressions provide Unicode character classses and Unicode property escapes for matching characters based on their Unicode values and Unicode properties respectively. When using Unicode property escapes like `+\p{Alpha}+` without the `+u+` flag, the regular expression will not match alphabetic characters but rather the `+'\p{Alpha}+'` string literal, which is likely a mistake.
|
|
|
|
This rules raises an issue when Unicode character classses and Unicode property escapes are used without the `+u+` flag.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
/\u{1234}/
|
|
/\p{Alpha}/
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
/\u{1234}/u
|
|
/\p{Alpha}/u
|
|
----
|
|
|
|
|