my question here
I am unable to replace a pattern using the method re.sub()
# expected result is <rule stage="Source"> how ever I am getting <?xml version="1.0" encoding="UTF-8"?#><rule stage="Source"> please help
I am unable to replace a pattern using the method re.sub()
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import re #initialize string x = '<?xml version="1.0" encoding="UTF-8"?><rule stage="Source">' #extracting a part of string b = re.findall( '(<.+\s.+\?>)' ,x) ##result will be b=['<?xml version="1.0" encoding="UTF-8"?>'] #now I want to remove the extract part so I am using print (re.sub(b[ 0 ],'',x)) |