使用!作为 Android Studio 的 TODO 过滤器的正则表达式中的文字字符

问题描述 投票:0回答:1

我正在遵循这个官方指南,了解如何在 Android Studio 中设置自定义 TODO 过滤器。

我需要对非 TODO 的重要评论进行突出显示,例如:

// important: this note is much more important than other comment lines
// !!!: this note is also much more important than other comment lines
// normal comment

使用这个正则表达式它可以工作:

\bimportant\b.*

如何用

!!!
设置滤镜?

我尝试过这些但没有成功:

\b!+\b.*
\b!!!\b.*
\b[!]+\b.*
\b[!!!]\b.*
\b\!\b.*
\b\!\!\!\b.*
\b(important|\x0021)+\b.*

谢谢

regex
1个回答
0
投票

您缺少的是

!
算作符号而不是单词的一部分,因此
\b
无法看到/识别其周围的单词边界。您需要使用类似
!!!.*
的东西来捕获带有 3 !

的线
© www.soinside.com 2019 - 2024. All rights reserved.