1
这是 Python split by regex look behind控制代码
一个更新的问题,我需要把控制代码中的正则表达式像0X0A 0X0D,或像0x07的0×00
当我使用下面的代码的任何其它控制代码,结果是不正确的:
import re
a = '''aaaaa
bbbb
cccc
'''
x = re.findall(r"[^%s]+%s" % (0x0a,0x0a),a,re.DOTALL)
print x
我[]
。
我可以使用Python split by regex look behind中的答案作为控制代码是0x0a==\n
,那么其他控制代码呢?
' “[^%S] +%的” %(0X0A,0X0A)''=='[^ 10] 10 “'。所以实际上你使用'x = re.findall(r'[^ 10] +10',a,re.DOTALL)'而不是'x = re.findall(r'[^ \ n] + \ n' ,a,re.DOTALL)'。 –
@KevinGuan谢谢,我现在得到了答案 – Boying
然后发布它作为答案。 –