rspec/rules/S5994/python/rule.adoc

25 lines
594 B
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
[source,python]
----
import re
pattern1 = re.compile(r"a++abc", re.DOTALL) # Noncompliant, the second 'a' never matches
pattern2 = re.compile(r"\d*+[02468]", re.DOTALL) # Noncompliant, the sub-pattern "[02468]" never matches
----
=== Compliant solution
[source,python]
----
import re
pattern1 = re.compile(r"aa++bc", re.DOTALL) # Compliant, for example it can match "aaaabc"
pattern2 = re.compile(r"\d*+(?<=[02468])", re.DOTALL) # Compliant, for example, it can match an even number like "1234"
----