2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-10-28 14:56:25 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-10-28 14:56:25 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-28 14:56:25 +02:00
|
|
|
----
|
|
|
|
r"(?:)*" # same as the empty regex, the '*' accomplishes nothing
|
|
|
|
r"(?:|x)*" # same as the empty regex, the alternative has no effect
|
|
|
|
r"(?:x|)*" # same as 'x*', the empty alternative has no effect
|
|
|
|
r"(?:x*|y*)*" # same as 'x*', the first alternative would always match, y* is never tried
|
|
|
|
r"(?:x?)*" # same as 'x*'
|
|
|
|
r"(?:x?)+" # same as 'x*'
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-10-28 14:56:25 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-28 14:56:25 +02:00
|
|
|
----
|
|
|
|
r"x*"
|
|
|
|
----
|
|
|
|
|