All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.S6594.html Maven / Gradle / Ivy

There is a newer version: 5.0.0.6962
Show newest version

Why is this an issue?

String.match() behaves the same way as RegExp.exec() when the regular expression does not include the global flag g. While they work the same, RegExp.exec() can be slightly faster than String.match(). Therefore, it should be preferred for better performance.

The rule reports an issue on a call to String.match() whenever it can be replaced with semantically equivalent RegExp.exec().

'foo'.match(/bar/);

Rewrite the pattern matching from string.match(regex) to regex.exec(string).

/bar/.exec('foo');

Resources

Documentation





© 2015 - 2025 Weber Informatics LLC | Privacy Policy