2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-11-03 09:18:19 +01:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-11-03 09:18:19 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-11-03 09:18:19 +01:00
|
|
|
----
|
|
|
|
r"[0-99]" # Noncompliant, this won't actually match strings with two digits
|
|
|
|
r"[0-9.-_]" # Noncompliant, .-_ is a range that already contains 0-9 (as well as various other characters such as capital letters)
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-11-03 09:18:19 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-11-03 09:18:19 +01:00
|
|
|
----
|
|
|
|
r"[0-9]{1,2}"
|
|
|
|
r"[0-9.\\-_]"
|
|
|
|
----
|
|
|
|
|