Remove everything before string in Notepad++

Viewed 26365

I would like to remove everything before a string 'EXEC'. How to do that in Notepad++?

There are many examples with regular expressions and special characters but my sentence has two EXEC so none of them solved my problem. I want to ignore EXECUTION and remove everything before EXEC.

Example:

Abcdefghijklmn EXECUTION EXEC myfilename here

Expected Result:

EXEC myfilename here
2 Answers

Try this Regex:

^.*(?=EXEC\s)

Click for Demo

Explanation:

  • ^ - Start of the String
  • .* - 0+ occurrences of any character which is not a newline character
  • (?=EXEC\s) - Positive lookahead which returns the position which is immediately followed by EXEC(with a space)

OUTPUT:

Before replacing:

enter image description here

After replacing:

enter image description here

You can replace the following regexp:

.*EXEC

with:

EXEC
Related