我应该使用哪个正则表达式来忽略 IDEA 中自动生成的 TODO?

发布于 2024-12-10 16:31:33 字数 223 浏览 1 评论 0原文

在 IntelliJ 中的 TODO 列表中,我想忽略自动生成的 TODO,例如:

// TODO Auto-generated method stub

我正在尝试以下正则表达式,但没有成功:

\btodo\b^(?!Auto-generated).*

我错过了什么?

提前致谢。

In my TODO list in IntelliJ, I'd like to ignore auto-generated TODOs such as:

// TODO Auto-generated method stub

I'm trying the following regex without success:

\btodo\b^(?!Auto-generated).*

What am I missing?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝眼泪 2024-12-17 16:31:33

^ 放置不正确。试试这个:

TODO (?!Auto-generated).*

The ^ is not placed correctly. Try this:

TODO (?!Auto-generated).*
锦欢 2024-12-17 16:31:33
TODO\s?(?!Auto-generated)

这有用吗?

TODO\s?(?!Auto-generated)

does this work?

檐上三寸雪 2024-12-17 16:31:33
// \btodo\b^(?!\[Auto-generated\]).*
// 
// Assert position at a word boundary «\b»
// Match the characters “todo” literally «todo»
// Assert position at a word boundary «\b»
// Assert position at the beginning of the string «^»
// Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!\[Auto-generated\])»
//    Match the character “[” literally «\[»
//    Match the characters “Auto-generated” literally «Auto-generated»
//    Match the character “]” literally «\]»
// Match any single character that is not a line break character «.*»
//    Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»

所以基本上这个正则表达式可能永远不会匹配。你匹配一个单词然后匹配字符串的开头?怎么会发生这种事呢?另外,您忽略//,您的大写是错误的,并且您在否定前瞻中转义了括号。这似乎与您的输入不匹配...

// \btodo\b^(?!\[Auto-generated\]).*
// 
// Assert position at a word boundary «\b»
// Match the characters “todo” literally «todo»
// Assert position at a word boundary «\b»
// Assert position at the beginning of the string «^»
// Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!\[Auto-generated\])»
//    Match the character “[” literally «\[»
//    Match the characters “Auto-generated” literally «Auto-generated»
//    Match the character “]” literally «\]»
// Match any single character that is not a line break character «.*»
//    Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»

So basically this regex will probably never match. You match a word and then you match the start of the string? How can this ever happen? Also you ignore //, your capitalization is wrong and you escape brackets inside your negative lookahead. This does not seem to match your input...

水波映月 2024-12-17 16:31:33

你忘了考虑空格(以及它之前的任何内容),为什么你在它周围放了 [] ?短语中没有您想要匹配的位置

TODO(?!.*Auto-generated).*

you forgot to account for the space (and anything that might precede it) and why did you put [] around it? it's nowhere in the phrase that you want to match

TODO(?!.*Auto-generated).*
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文