答案1
以下是使用 Notepad++ 完成此工作的方法:
- Ctrl+H
- 找什么:
^.*?(?:user5@other\.com|([^\s,:]+@[^\s:,]+)).*?$
- 用。。。来代替:
(?1$1:)
- 查看 相符
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
^ # beginning of line
.*? # 0 or more any character but newline, not greedy
(?: # non capture group
user5@other\.com # literally
| # OR
( # group 1
[^\s,:]+ # 1 or more any character that is not space, comma or colon
@ # @
[^\s,:]+ # 1 or more any character that is not space, comma or colon
) # end group 1
) # end group
.*? # 0 or more any character but newline, not greedy
$ # end of line
替代品:
(?1 # if group 1 exists
$1 # take it
: # else, nothing
) # endif
截图(之前):
截图(之后):