问题
I have this piece of code
private static final Pattern controlChars = Pattern.compile(
"[\u0001-\u0008\u000B\u000C\u000E-\u001F\u007F]");
and IntelliJ idea (2016.3) puts a red squiggle under \u0008 saying it's an illegal/unsupported escape sequence. Changing it to any of \b, \010 or \x08 has no effect.
What I don't get is that the code builds and runs without a problem. Any idea what's the issue?
回答1:
This is a bug in the RegExp support. It is fixed in IntelliJ IDEA 2017.1 Public Preview.
You can remove the (harmless) error by positioning the text cursor on the error, typing Alt+Enter and invoking Un-inject Language/Reference. However this will also disable all other RegExp features on this literal.
来源:https://stackoverflow.com/questions/42537321/intellij-says-b-backspace-is-an-illegal-escape-sequence-inside-a-string-liter