मेरा उद्देश्य, एक स्ट्रिंग और जहां कभी एक पूर्णांक या हेक्साडेसिमल नंबर मिल पढ़ा की जगह उस के साथ करने के लिए है "[0-9]" मेरे स्ट्रिंग है:नियमित अभिव्यक्ति और कुछ अन्य तार
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)
निम्नलिखित उत्पादन प्राप्त करें::
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
लेकिन outpu निम्नलिखित के साथ की कोशिश की है टी इस तरह होना चाहिए:
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]
'आर '(0x [ए-एफए च \ घ] | \ d +)' उपयोग करने का प्रयास' regex के रूप में। – Blender