rspec/rules/S5850/php/rule.adoc

36 lines
359 B
Plaintext
Raw Normal View History

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,php]
----
/^a|b|c$/
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,php]
----
/^(?:a|b|c)$/
----
or
2022-02-04 17:28:24 +01:00
[source,php]
----
/^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,php]
----
/(?:^a)|b|(?:c$)/
----