0

Is there any way to be able to catch all exceptions when doing string matching? For example if I have a string,

print("red" =="red" )
# evaluates to True

However,

print("Rεժ" == "red")
# evaluates to False

What I would like is to be able to catch all the special cases such as the following

print("Rεժ" == "red")
print("RêÐ" == "red")

to be evaluated to be True. The use-case for this is to be able to have some sort of text filtering to be able to catch all the words "red".

milanbalazs
  • 4,811
  • 4
  • 23
  • 45
Axois
  • 1,961
  • 2
  • 11
  • 22

1 Answers1

0

As Tomalak and Laurens Koppenol eluded to in the comments, this could be a possible duplicate of other SO questions involving UTF8 or Unicode characters with accent marks, but the following code returned true for me:

import unidecode

accented_string = u'RêÐ'
unaccented_string = unidecode.unidecode(accented_string)
print(unaccented_string.lower() == "red")
Max Voisard
  • 1,685
  • 1
  • 8
  • 18