I have a string, such as u'jdiajsi--dasdsa\xa0'. I need to get rid of \xao and obtain u'jdiajsi--dasdsa'.
First, I tried str.replace("\xa0", ", "), but it does not work. Then, I change to re.sub(r'\W+', ' ', str), but the result is "jdiajsi dasdsa". The two dashes are gone...
str = "jdiajsi--dasdsa\xa0"
str.replace("\xa0", ", ") #fail
re.sub(r'\W+', ' ', str) #fail
The first result is no change, the second one miss --. The expected result is "jdiajsi--dasdsa"
The input is unicode rather than a string