python的正则出错——raise error:("multiple repeat ")

来源:互联网 发布:php 500错误如何排查 编辑:程序博客网 时间:2024/06/01 09:40

句子中可能出现了通配符

我碰到的情况是:

在一个函数中,截取部分内容。


——re.sub(st,'',text)

——其中,st='天气真***好'

——text = '今天天气真***好啊'

——然后就会报错了。


  File "D:\python34\lib\sre_parse.py", line 569, in _parse
    raise error("multiple repeat")
sre_constants.error: multiple repeat

可以加一个预处理模块,把所有的*转为别的字符,如#来处理。