2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-10-29 09:54:32 +02:00
|
|
|
include::../description.adoc[]
|
2021-09-06 16:45:18 +02:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-09-06 16:45:18 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2021-09-06 16:45:18 +02:00
|
|
|
----
|
|
|
|
str.split(/.*?x?/); // Noncompliant, this will behave just like "x?"
|
|
|
|
/^.*?$/.test(str); // Noncompliant, replace with ".*"
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-09-06 16:45:18 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2021-09-06 16:45:18 +02:00
|
|
|
----
|
|
|
|
str.split(/.*?x/);
|
|
|
|
/^.*$/.test(str);
|
|
|
|
----
|
|
|
|
|