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
bar@hotmail.
com
bas@gmail
qux@abc.
com
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 xxx@xxx.
com also
And the result become like this after i enter the command above
foo@gmail.
com
bar@hotmail.
com.com
bas@gmail.
com
qux@abc.
com.com
mike@abc.
com
john@email.
com
So, My expectation after substitution is should be like this:
foo@gmail.
com
bar@hotmail.
com
bas@gmail.
com
qux@abc.
com
mike@abc.
com
john@email.
com
How to use regex in this situation?