Java

Java

By DeepSource

Invalid regex syntax must not be used JAVA-E0394

Bug risk

Invalid regex strings will throw a PatternSyntaxException at runtime.

This code attempts to compile a regular expression string that is invalid according to Java's syntax for regular expressions. Because of this, a PatternSyntaxException will be thrown when this statement is executed.

Bad Practice

Pattern.compile("(\\)");

Recommended

Perhaps the intention was to match on a single \\ character:

Pattern.compile("(\\\\)");

References