【问题标题】:Match lines which don't start with a comment (after any number of tabs)匹配不以注释开头的行(在任意数量的制表符之后)
【发布时间】:2017-10-09 22:37:56
【问题描述】:

我使用负前瞻来查找不以注释开头的每一行(仅“//”),但在“//”符号之前可以有任意数量的制表符。

这是我的正则表达式(我使用的是记事本++):

^\t*(?!//).*

示例:在此示例文件中:

                LineOfCode ...
                // Other Comment
                // Comments can contain every time of symbol, including "//", ".", etc.
                // /**
                    // Another comment ...
                // */
                Line Of Code ...
                    // .,.,-

只有第一行和第七行应该匹配,但使用我的正则表达式,它们都匹配。

【问题讨论】:

    标签: regex notepad++ negative-lookahead


    【解决方案1】:

    使用

    ^(?!\h*//).*
    

    ^(?!\h*//) 前瞻匹配以 0+ 个水平空格开头然后是 // 的行,然后匹配该行的其余部分。

    请参阅regex demo

    使用这些选项:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      • 1970-01-01
      • 2013-05-23
      • 2023-02-09
      • 2022-07-29
      相关资源
      最近更新 更多