20 lines
496 B
Plaintext
20 lines
496 B
Plaintext
== Why is this an issue?
|
|
|
|
Entries in the ASCII table below code 32 are known as control characters or non-printing characters. As they are not common in JavaScript strings, using these invisible characters in regular expressions is most likely a mistake.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
const pattern1 = /\x1a/;
|
|
const pattern2 = new RegExp('\x1a');
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
const pattern1 = /\x20/;
|
|
const pattern2 = new RegExp('\x20');
|
|
----
|