2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-10-29 15:28:30 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-10-29 15:28:30 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-29 15:28:30 +02:00
|
|
|
----
|
|
|
|
r"^a|b|c$"
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-10-29 15:28:30 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-29 15:28:30 +02:00
|
|
|
----
|
|
|
|
r"^(?:a|b|c)$"
|
|
|
|
----
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-29 15:28:30 +02:00
|
|
|
----
|
|
|
|
r"^a$|^b$|^c$"
|
|
|
|
----
|
|
|
|
|
|
|
|
or, if you do want the anchors to only apply to ``a`` and ``c`` respectively:
|
|
|
|
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,python]
|
2021-10-29 15:28:30 +02:00
|
|
|
----
|
|
|
|
r"(?:^a)|b|(?:c$)"
|
|
|
|
----
|