Search code examples
regexjedit

Regex Extract Delete all but Customer Code:


I have a long text file and I want to save all the lines that are similar to the following:

Customer Code: BER17O

How can I use REGEX to delete all the data except these lines?


Solution

  • Use multiline option with this regex

    ^(?!Customer Code: \w+$).*$


    OR[if you want to be specific]

    ^(?!Customer Code: BER17O$).*$


    (?!) is a negative lookahead which doesnt match the line if the line starts with Customer Code: followed by the word!