Search code examples
regexnotepad++regular-language

Regex to invert search in Notepad++


I have a string

2012-02-19 00:11:12,128|DEBUG|Thread-1|@@@ Time taken is 18 ms 

Below regex allows me to search for 18 ms

\d\d\s[m][s]

What I want to do is search for string prior to 18 ms in Notepad++ and then delete it. So that out of thousands rows I have, I can just extract out timings.

Also, I need regex mentioned above to work with timings which are in 3 digits as well as 2 digits. For example it should be able to search for 18 ms as well as 999 ms.

Please help.


Solution

  • Also, I need regex mentioned above to work with timings which are in 3 digits as well as 2 digits.

    .*?(?=\d{2,3}\sms\b)
    

    Use the above regex and then replace the match with empty string.