How to put .com at the end of email addressed by regex?
Posted
by
terces907
on Stack Overflow
See other posts from Stack Overflow
or by terces907
Published on 2013-10-28T20:43:49Z
Indexed on
2013/10/28
21:53 UTC
Read the original article
Hit count: 325
Example
I received a email-list from my friends but the problem is some people typed an email in full form ([email protected]) and some people typed (xxx@xxx without .com). And i want to improve it into the same format. How can i improve it if i want to edit them on vi?
In my emaillist.txt
foo@gmail
[email protected]
bas@gmail
[email protected]
mike@abc
john@email
My try:
i tried to use an easy regex like this to catch the pattern like xxx@xxx
:%s/\(\w*@\w*\)/\0.com/g
and
:%s/\(\w*@\w*[^.com]\)/\0.com/g
But the problem is this regex include [email protected] also
And the result become like this after i enter the command above
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
So, My expectation after substitution is should be like this:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
How to use regex in this situation?
© Stack Overflow or respective owner