-1

for example i want to do

new_data = t = re.sub('[ufd3e]'),' ',new_data)

to replace the character uf3ef but it doesn't work

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Moun
  • 325
  • 2
  • 16
  • 1
    Did you try [reading the documentation](https://docs.python.org/3/library/re.html)? – Karl Knechtel May 30 '20 at 06:56
  • Python accepts utf-8 by default. You likely can just put `'[﴾]'` in your code. – tdelaney May 30 '20 at 07:13
  • `\ufd3e` works, but no need for square brackets, which means "choose one of", when you only have one character. For that matter, no need for a regular expression at all. Just use `new_data = new_data.replace('\ufd3e',' ')`. – Mark Tolonen May 30 '20 at 09:56

1 Answers1

0

you need to use \u to tell it it is unicode (and you had a closing parenthesis in the wrong place)

new_data = t = re.sub(u'[\ufd3e]',' ',new_data)
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179