Notepad++ use both regular expressions and extended search

前端 未结 2 481
既然无缘
既然无缘 2020-12-20 08:33

I need to find all \\r\\n that do not precede the letter M;
Seems I can\'t do this:

\\r\\n[^M]

I can only do \\r\\n<

相关标签:
2条回答
  • 2020-12-20 08:53

    \r\n is valid with Regular expression checked in the Find tab too - i.e. not just with Extended checked: why not just use \r\n[^M] with Regular expression checked?

    Given the following test text...

    whatever
    M
    whatever
    G
    foo
    

    ..., \r\n[^M] yields the expected results below...

    Search "\r\n[^M]" (3 hits in 1 file)
      new  2 (3 hits)
        Line 2: M
        Line 3: whatever
        Line 4: G
    

    ..., the matches being at the ends of the matched lines of course.

    0 讨论(0)
  • 2020-12-20 08:54

    You should instead use this regex:

    \R(?!M)
    

    Explanation:

    • \R Any Unicode newline sequence.
    • (?!M) Negative Lookahead: Assert "M" cannot be matched.
    0 讨论(0)
提交回复
热议问题