Python regex to remove all words which contains number

后端 未结 2 1016
夕颜
夕颜 2020-12-16 00:01

I am trying to make a Python regex which allows me to remove all worlds of a string containing a number.

For example:

in = \"ABCD abcd AB55 55CD A55D         


        
2条回答
  •  长情又很酷
    2020-12-16 00:49

    Here's my approach:

    >>> import re
    >>> s = "ABCD abcd AB55 55CD A55D 5555"
    >>> re.sub("\S*\d\S*", "", s).strip()
    'ABCD abcd'
    >>>
    

提交回复
热议问题