Determining the unmatched portion of a string using a regex in Python

前端 未结 4 1466
梦谈多话
梦谈多话 2021-01-12 12:50

Suppose I have a string \"a foobar\" and I use \"^a\\s*\" to match \"a \".

Is there a way to easily get \"foobar\" returned? (What was NOT matched)

I want to

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-12 13:46

    >>> import re
    >>> re.sub("87\s*", "", "87 foo 87 bar")
    'foo bar'
    

提交回复
热议问题