0

I have a large log file that contains email addresses mixed in with some other content. Each line contains an email address as well as some other text, like:

I can match the email addresses in vim but I'd like to remove all the content that doesn't match an email address, leaving me with a single address per line. How can I do that with a regex search?

Hibiscus
  • 592
  • 4
  • 11

1 Answers1

0

if you have already successfully matched the email address, you can do :

:%s/.\{-}\(yourPattern\).*/\1/g

for example:

%s/.\{-}\(\S\+@\S\+\).*/\1/

here the \S\+@\S\+ is the pattern. for sure it is not the good try for matching an email address.

Kent
  • 189,393
  • 32
  • 233
  • 301