include::../description.adoc[]

== Noncompliant Code Example
[source,php]
----
preg_match("/Jack|Peter|/", "John"); // Noncompliant - returns 1
preg_match("/Jack||Peter/", "John"); // Noncompliant - returns 1
----
== Compliant Solution
[source,php]
----
preg_match("/Jack|Peter/", "John"); // returns 0
----

== Exceptions

One could use an empty alternation to make a regular expression group optional. Rule will not report on such cases.

----
preg_match("/mandatory(-optional|)/", "mandatory"); // returns 1
preg_match("/mandatory(-optional|)/", "mandatory-optional"); // returns 1
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

== Message

Remove this empty alternative.

== Highlighting

The | should be highlighted.

'''

endif::env-github,rspecator-view[]
