我有一个很大的.doc文件,其中包含很多客户信息,我需要使用以下逻辑查找/替换:
Surname1 Surname2, Name -> Name.Surname1.Surname2@xxxxxx.com
我试图弄乱notepad ++,但我实际上并不具备正则表达式所需的知识。
来自评论
Jordan Parks
Kevin Johanson Larsson
Oleg Garcia Cruz
Jose Rondo Curry
Tim Bush Gallagher
Victoria
答案 0 :(得分:1)
使用记事本++,您可以执行以下操作:
^(\S+)\h*(\S+)?\h*(\S+)?$
(?3$3.$1.$2:(?2$2.$1:$1))@xx.com
说明:
^ : beginning of line
(\S+) : group 1, 1 or more non space character
\h* : 0 or more horizontal spaces
(\S+)? : optional group 2, 1 or more non space character
\h* : 0 or more horizontal spaces
(\S+)? : optional group 3, 1 or more non space character
$ : end of line
替换:
(?3 : if group 3 exists
$3.$1.$2 : concatenate group 3 (name) then group 1 (surname1) then group 2 (surname2)
: : else (group 3 does not exist)
(?2 : if group 2 exists
$2.$1 : concatenate group 2 (name) then group 1 (surname1)
: : else, group 2 does not exist
$1 : group 1 (name)
)
)
@xx.com : literally
给出:
Jordan Parks
Kevin Johanson Larsson
Oleg Garcia Cruz
Jose Rondo Curry
Tim Bush Gallagher
Victoria
给定示例的结果
Parks.Jordan@xx.com
Larsson.Kevin.Johanson@xx.com
Cruz.Oleg.Garcia@xx.com
Curry.Jose.Rondo@xx.com
Gallagher.Tim.Bush@xx.com
Victoria@xx.com