> This is my command to search emails:
> \([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)
>
> p.e.
>
> myemail@mydomain.com hello myotheremail@mydomain.com
> hello mylatestemail@mydomain.co.uk
>
> Putting that in your command gives an empty output (it removes the
> emails).
Ah...with that context, I might try to approach the problem
differently. If you don't mind newlines being added when more
than one email was on the same line, I might do something like
:%s/\([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)/\r&\r/g
:v/^\([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)$/d
The first one puts each email address alone on a line, and the
second one deletes all lines that don't have an email address on
them. Given your example, one might also have to add "\c" to
your pattern to make it case-insensitive (your regexp only finds
uppercase email addresses).
If you need to keep emails on the same line back together, it
might take a little more work.
-tim
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment