Capturing repeating subpatterns in Python regex

前端 未结 4 1084
难免孤独
难免孤独 2020-11-22 05:21

While matching an email address, after I match something like yasar@webmail, I want to capture one or more of (\\.\\w+)(what I am doing is a little

4条回答
  •  被撕碎了的回忆
    2020-11-22 06:10

    This is what you are looking for:

    >>> import re
    
    >>> s="yasar@webmail.something.edu.tr"
    >>> r=re.compile("\.\w+")
    >>> m=r.findall(s)
    
    >>> m
    ['.something', '.edu', '.tr']
    

提交回复
热议问题