Amacım, bir dize ve nereye kadar bir tamsayı veya onaltılık sayısını bulmak okumak o değiştirmektir diğer bazı dizeleri "[0-9]" Benim dizesidir:onaltılık için düzenli ifade ve
a = hello word 123 with the 0x54673ef75e1a
a1 = hello word 123 with the 0xf
a2 = hello word 123 with the 0xea21f
a3 = hello word 123 with the 0xfa
b = re.sub(r"(\d+[A-Fa-f]*\d+[A-Fa-f]*)|(\d+)","[0-9]",a)
aşağıdaki çıktıyı alın:
hello word [0-9] with the [0-9]x[0-9]a
hello word [0-9] with the [0-9]xf
hello word [0-9] with the [0-9]xea[0-9]
hello word [0-9] with the [0-9]xfa
Ama outpu aşağıdaki denediniz Böyle davranma olmalıdır:
hello word [0-9] with the [0-9]
hello word [0-9] with the [0-9]
hello word [0-9] with the [0-9]
hello word [0-9] with the [0-9]
http://ideone.com/nMMNJm 'r' (\ d + 0 x [A-fa-f \ d] +) kullanılarak deneyin bakınız. – Blender