正则表达式匹配字符串python
我想匹配以下字符串:正则表达式匹配字符串python,python,regex,Python,Regex,我想匹配以下字符串: strings = iamcool.iplay=ball?end 我想删除从“.”开始一直到“?”的项目,所以我想删除.iplay=ball,所以我应该有iamcool?end 这是我的正则表达式: print re.sub(r'\.\.*?','', strings) 我不知道如何停止在“?”使用否定字符类[^?],该类匹配除?之外的任何内容 >>> re.sub(r'\.[^?]*', '', strings) 'strings = iamcool
strings = iamcool.iplay=ball?end
我想删除从“.”开始一直到“?”的项目,所以我想删除.iplay=ball
,所以我应该有iamcool?end
这是我的正则表达式:
print re.sub(r'\.\.*?','', strings)
我不知道如何停止在“?”使用否定字符类
[^?]
,该类匹配除?
之外的任何内容
>>> re.sub(r'\.[^?]*', '', strings)
'strings = iamcool?end'