IntelliJ说\ b(退格键)是字符串文字中的非法转义序列.为什么? [英] IntelliJ says \b (backspace) is an illegal escape sequence inside a string literal. Why?

查看:373
本文介绍了IntelliJ说\ b(退格键)是字符串文字中的非法转义序列.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码

private static final Pattern controlChars = Pattern.compile(
        "[\u0001-\u0008\u000B\u000C\u000E-\u001F\u007F]");

和IntelliJ idea(2016.3)在\u0008下放置了一个红色的花体,表示这是非法/不受支持的转义序列.将其更改为\b\010\x08中的任何一个均无效.

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?

推荐答案

这是RegExp支持中的错误.它在

This is a bug in the RegExp support. It is fixed in IntelliJ IDEA 2017.1 Public Preview.

您可以通过以下操作来消除(无害)错误:将文本光标放在错误上,键入 Alt + Enter 并调用Un-inject Language/Reference.但是,这也会禁用此文字上的所有其他RegExp功能.

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.

这篇关于IntelliJ说\ b(退格键)是字符串文字中的非法转义序列.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆