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
然後發佈它作爲答案。 –