我想从下面的twitter文本中提取困惑的标点符号(任意数字的组合!)。python:用正则表达式提取困惑的标点符号
string4 = 'on my god!!!!,I think he is right?!, but what about he!??, but me !!??, yes !?!?, and my god ?!?.'
我用下面的正则表达式:
p_excitement = re.compile(r'!{1,}\?{1,}')
m = p_excitement2.findall(string4)
但结果是:
['!??', '!!??', '!?', '!?', '!?']
这是错误的。我希望得到以下结果(请注意,我想任何疑惑标点符号不只是下面的文字):
['?!', '!??', '!!??', '!?!?', '?!?']
感谢您的帮助!
普莱斯考虑接受所提供的正确答案第一。 –