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