31 lines
571 B
Plaintext
31 lines
571 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
To match a literal string instead of a regular expression, either all special characters should be escaped, the `RegexOption.LITERAL` flag or functions that don't use regular expressions should be used.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,kotlin]
|
|
----
|
|
Regex("([")
|
|
"([".toRegex()
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,kotlin]
|
|
----
|
|
Regex("\\(\\[")
|
|
Regex("""\(\[""")
|
|
"\\(\\[".toRegex()
|
|
"""\(\[""".toRegex()
|
|
|
|
Regex("([", RegexOption.LITERAL)
|
|
"([".toRegex(RegexOption.LITERAL)
|
|
----
|
|
|
|
include::../rspecator.adoc[]
|