28 lines
514 B
Plaintext
28 lines
514 B
Plaintext
== Why is this an issue?
|
||
|
||
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,python]
|
||
----
|
||
re.compile(r"([")
|
||
re.sub(r"([", input, "{")
|
||
re.compile(r"(\w+-(\d+)")
|
||
----
|
||
|
||
|
||
=== Compliant solution
|
||
|
||
[source,python]
|
||
----
|
||
re.compile(r"\(\[")
|
||
input.replace("([", "{")
|
||
re.compile(r"(\w+)-(\d+)")
|
||
----
|
||
|
||
include::../rspecator.adoc[]
|