比较简单,python源码如下:
# -*- coding:utf-8 -*-
__author__ = 'ppdy'
import re
import pyperclip
# xxx.yyy@126.com
def regex_t():
regex = re.compile(r'''
[a-z0-9A-z_\.]+ #
@ # @
[a-z0-9A-z_\.]+ # domain name
\.[a-zA-Z]{2,4} #
''', re.VERBOSE)
str1 = ''' \
xxx.yyy@163.com fdsfdf
dfsdf
sfsdf tom.cat@163.com
ddfdfdf
'''
result = regex.findall(pyperclip.paste())
print(result)
print(len(result))
clean_set = set(result)
print(len(clean_set))
str2 = '\n'.join(clean_set)
print(str2)
pyperclip.copy(str2)
# print(type(result))
if __name__ == '__main__':
regex_t()
1. 参考《Python编程快速上手++让繁琐工作自动化》第7章;
2. 需安装pyperclip模块,可使用pip安装;
3. 使用方式:复制一段含邮箱的文档--->运行本py文件--->粘贴、保存结果