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

org.sonar.l10n.py.rules.python.S5856.html Maven / Gradle / Ivy

There is a newer version: 4.23.0.17664
Show newest version

Why is this an issue?

Regular expressions have their own syntax that is understood by regular expression engines. Those engines will throw an exception at runtime if they are given a regular expression that does not conform to that syntax.

To avoid syntax errors, special characters should be escaped with backslashes when they are intended to be matched literally and references to capturing groups should use the correctly spelled name or number of the group.

To match a literal string, rather than a regular expression, either all special characters should be escaped or methods that don’t use regular expressions should be used.

Noncompliant code example

re.compile(r"([")
re.sub(r"([", input, "{")
re.compile(r"(\w+-(\d+)")

Compliant solution

re.compile(r"\(\[")
input.replace("([", "{")
re.compile(r"(\w+)-(\d+)")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy