Files
openide/java/java-impl/resources/inspectionDescriptions/EscapedSpace.html
2025-02-05 04:43:28 +00:00

19 lines
950 B
HTML

<html>
<body>
Reports <code>\s</code> 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 <code>\s</code> 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, <code>\s</code> is identical to an ordinary space character (<code>"&nbsp;"</code>).
<p><b>Example:</b></p>
<pre><code>
if (str.matches("\s+")) {...}
</code></pre>
Here it's likely that <code>"\\s+"</code> was intended (to match any whitespace character). If not, using <code>str.matches("&nbsp;+")</code>
would be less confusing.
<p>
A quick-fix is provided that replaces <code>\s</code> escapes with space characters.
</p>
<!-- tooltip end -->
<p><small>New in 2022.3</small></p>
</body>
</html>