Java

Java

Made by DeepSource

Avoid using a single unescaped . as a regex pattern JAVA-W1078

Anti-pattern
Major
Autofix

A single unescaped . in a regex pattern will match one of any character, not just the period character.

Consider escaping the . if you meant to match a single period instead.

Bad Practice

This regex matches anything but newlines, once:

Pattern p = Pattern.compile(".");

Recommended

Escape the pattern with two \ characters if you are matching a single period.

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