V6059. Odd use of special character in regular expression. Possibly, it was intended to be escaped.

The analyzer has detected a strange regular expression, the use of which leads to a result different from what the programmer expects.

Consider the following example:

String[] arr = "Hot. Cool. Yours".split(".");

After executing this line, the array will be lacking the expected elements {"Hot", " Cool", " Yours"}. Instead, it will be an empty array. This has to do with the fact that the dot is a special character in a regular expression and has its own purpose. To make a dot a separator in your string, use it as follows:

String[] arr = "Hot. Cool. Yours".split("\\.");

The analyzer will also warn you if your regular expression consists only of these characters:

  • "|"
  • "^"
  • "$"

This diagnostic is classified as:

Bugs Found

Checked Projects
Collected Errors
14 526
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →