netdzb 当前离线
上尉
#!/usr/bin/python import re str = "this is string ?example....wow!!! this is really string"; print re.sub(r'^?.','',str);复制代码
wujunkai 当前离线
六级士官
#!/usr/bin/python # -*- coding: UTF-8 -*- import re str = "this is string ?example....wow!!! this is really string" str = re.sub(r'(?<=[?|?]).+','',str) if str[-1]!='?' : str=str[:-1]+'?' print str复制代码
TOP
import re str = "this is string ? example....wow!!! this is really string" print re.sub(r'(?<=[?|?]).+','',str)复制代码