IntelliJ says \b (backspace) is an illegal escape sequence inside a string literal. Why?

放肆的年华 提交于 2019-12-07 08:13:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!