my question here
I am unable to replace a pattern using the method re.sub()
I am unable to replace a pattern using the method re.sub()
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))# expected result is <rule stage="Source"> how ever I am getting <?xml version="1.0" encoding="UTF-8"?#><rule stage="Source"> please help