11 lines
407 B
Plaintext
11 lines
407 B
Plaintext
![]() |
Alternation is used to match a single regular expression out of several possible regular expressions. If one of the alternatives is empty it would match any input, which is most probably a mistake.
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
----
|
||
|
/Jack|Peter|/.test('John'); // returns 'true'
|
||
|
/Jack||Peter/.test('John'); // returns 'true'
|
||
|
----
|
||
|
== Compliant Solution
|
||
|
----
|
||
|
/Jack|Peter/.test('John'); // returns 'false'
|
||
|
----
|