2022-02-02 16:59:48 +01:00
|
|
|
include::../description.adoc[]
|
2022-01-28 12:40:19 +00:00
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2022-01-28 12:40:19 +00:00
|
|
|
----
|
|
|
|
"(?:number)\d{2}"
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,php]
|
2022-01-28 12:40:19 +00:00
|
|
|
----
|
|
|
|
"number\d{2}"
|
|
|
|
"(?:number)?\d{2}"
|
|
|
|
----
|
|
|
|
|
|
|
|
== Exceptions
|
|
|
|
|
2022-03-24 17:23:48 +01:00
|
|
|
This rule does not report an issue if the non-capturing group is an alternation.
|
|
|
|
|
|
|
|
[source,php]
|
2022-01-28 12:40:19 +00:00
|
|
|
----
|
|
|
|
"(?:number|string)"
|
|
|
|
----
|
|
|
|
|
|
|
|
== See
|
|
|
|
|
|
|
|
https://www.php.net/manual/en/regexp.reference.subpatterns.php[Subpatterns] - PHP Documentation
|
|
|
|
|
2022-03-24 17:23:48 +01:00
|
|
|
include::../implementation.adoc[]
|