23 lines
506 B
Plaintext
23 lines
506 B
Plaintext
include::../description.adoc[]
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,python]
|
|
----
|
|
re.replace(r"start\w*?(end)?", "x", "start123endstart456") # Noncompliant. In contrast to what one would expect, the result is not "xx"
|
|
|
|
re.match(r"^\d*?$", "123456789") # Noncompliant. Matches the same as "/^\d*$/", but will backtrack in every position.
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,python]
|
|
----
|
|
re.replace(r"start\w*?(end|$)", "x", "start123endstart456") # Result is "xx"
|
|
|
|
re.match(r"^\d*$", "123456789")
|
|
----
|
|
|