23 lines
506 B
Plaintext
23 lines
506 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
|
|||
|
|
|||
|
----
|
|||
|
preg_match("/([/", $input);
|
|||
|
preg_replace("/[/", "{", $input);
|
|||
|
preg_replace("/(\\w+-(\\d+)/", "1234", $input);
|
|||
|
----
|
|||
|
|
|||
|
|
|||
|
== Compliant Solution
|
|||
|
|
|||
|
----
|
|||
|
preg_match("/\\(\\[/", $input);
|
|||
|
str_replace("([", "{", $input);
|
|||
|
preg_replace("/(\\w+)-(\\d+)/", "1234", $input);
|
|||
|
----
|
|||
|
|