\s
escape sequences anywhere except at text-block line endings or within a series of several escaped spaces.
Such usages can be confusing or a mistake, especially if the string is interpreted as a regular expression.
The \s
escape sequence is intended to encode a space at the end of text-block lines where normal spaces are trimmed.
In other locations, as well as in regular string or char literals, \s
is identical to an ordinary space character (" "
).
Example:
if (str.matches("\s+")) {...}
Here it's likely that "\\s+"
was intended (to match any whitespace character). If not, using str.matches(" +")
would be less confusing.
A quick-fix is provided that replaces \s
escapes with space characters.
New in 2022.3