Extract email sub-strings from large document

前端 未结 11 2232
星月不相逢
星月不相逢 2020-11-28 06:54

I have a very large .txt file with hundreds of thousands of email addresses scattered throughout. They all take the format:

......
         


        
11条回答
  •  我在风中等你
    2020-11-28 07:13

    Example : string if mail id has (a-z all lower and _ or any no.0-9), then below will be regex:

    >>> str1 = "abcdef_12345@gmail.com"
    >>> regex1 = "^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$"
    >>> re_com = re.compile(regex1)
    >>> re_match = re_com.search(str1)
    >>> re_match
    <_sre.SRE_Match object at 0x1063c9ac0>
    >>> re_match.group(0)
    'abcdef_12345@gmail.com'
    

提交回复
热议问题