39 lines
672 B
Plaintext
39 lines
672 B
Plaintext
:lookahead: php/lookahead.adoc
|
|
|
|
This rule raises an issue when a regex lookahead contradicts the rest of the regex.
|
|
|
|
|
|
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,php]
|
|
----
|
|
preg_match("/(?=a)b/", $str); // Noncompliant, the same character can't be equal to 'a' and 'b' at the same time
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,php]
|
|
----
|
|
preg_match("/(?<=a)b/", $str);
|
|
preg_match("/a(?=b)/", $str);
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|