Search code examples
regexsublimetext3

Delete all text but matches in SublimeText


I am trying to delete all strings except emails in sublime.

So i can look for emails like this

[a-zA-Z0-9.!#$%&'+-/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[\.a-zA-Z0-9-]+)

But how do i delete everything else?

Thanks


Solution

  • You may do the following:

    • Use your regex to find all emails, click Find All to select all emails
    • Go to Selection and click Invert Selection
    • Press Enter to add line breaks between the found emails. Or, press , or any other key to insert anything to delimit found matches.