Regex 记事本++;正则表达式用于为行添加书签

Regex 记事本++;正则表达式用于为行添加书签,regex,notepad++,Regex,Notepad++,我有这样的行列表 c:\names1\ex1 c:\names2\ex2 c:\names3\ex14 http://example1 http://example3 c:\names4\ex15 http://example4 c:\names4\ex17 c:\names4\ex18 我想使用正则表达式来标记后面跟c:\的所有行,作为行的开始,而不是http,在这种情况下,应该标记前两行和最后两行。 因为其他“行以c:too开头”后跟http:\作为行的开头,所以您可以使用以下模式: ^c

我有这样的行列表

c:\names1\ex1
c:\names2\ex2
c:\names3\ex14
http://example1
http://example3
c:\names4\ex15
http://example4
c:\names4\ex17
c:\names4\ex18
我想使用正则表达式来标记后面跟c:\的所有行,作为行的开始,而不是http,在这种情况下,应该标记前两行和最后两行。
因为其他“行以c:too开头”后跟http:\作为行的开头,所以您可以使用以下模式:

^c:.*+(?!\r?\nhttp:)
图案详情:

^                # anchor for the start of the line
c:      
.*+              # zero or more characters until the end of line (possessive)
(?!\r?\nhttp:)   # not followed by a newline and http:

您可以使用以下模式:

^c:.*+(?!\r?\nhttp:)
图案详情:

^                # anchor for the start of the line
c:      
.*+              # zero or more characters until the end of line (possessive)
(?!\r?\nhttp:)   # not followed by a newline and http:

有一种简单的方法可以实现这一点

  • 转到搜索查找..>选择标记选项卡。确保在“搜索模式”框下选中了正则表达式,并确保选中了书签行

  • 您要搜索以下内容,但仍在标记下

    Find what: ^c:\S++(?!\r?\nhttp)
    
  • 最后,单击“标记所有”,为这些行添加书签


  • 有一种简单的方法可以实现这一点

  • 转到搜索查找..>选择标记选项卡。确保在“搜索模式”框下选中了正则表达式,并确保选中了书签行

  • 您要搜索以下内容,但仍在标记下

    Find what: ^c:\S++(?!\r?\nhttp)
    
  • 最后,单击“标记所有”,为这些行添加书签


  • 谢谢你的解释谢谢你的解释