23 lines
450 B
Plaintext
23 lines
450 B
Plaintext
include::../description.adoc[]
|
|
|
|
To match a literal string, rather than a regular expression, either all special characters should be escaped or methods that don't use regular expressions should be used.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,javascript]
|
|
----
|
|
new RegExp("([");
|
|
str.match("([");
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,javascript]
|
|
----
|
|
new RegExp("\\(\\[");
|
|
str.match("\\(\\[");
|
|
str.replace("([", "{");
|
|
----
|
|
|
|
include::../rspecator.adoc[]
|