Hi, I have a problem in python. I am trying to explain my problem with an example.
I have this line:
>>> string = 'ÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÀÁÂÃ' >>> print string ÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÀÁÂÃ
and I want, for example, to replace charachters other than Ñ, Ã, ï with ""
I tried:
>>> rePat = re.compile('[^ÑÃï]',re.UNICODE) >>> print rePat.sub("",string) Ñ ï Ã
I got it. I think this is because this type of character in python is represented by two positions in the vector: for example, \ xc3 \ x91 = Ñ. To do this, when I do the regex expression, all \ xc3 are not replaced. How can I make this type sub ?????
Thanks Franco
Franco
source share