My code only finds (and deletes) vowels in English. How can I make it find (and delete) vowels in Russian (or other languages)?
import re
def test(text):
return re.sub(r'[aeiou] ', '', text, flags=re.IGNORECASE)
text = "Python";
print("Original string:",text)
print("After removing all the vowels from the said string: " test(text))
text = "C Sharp"
print("\nOriginal string:",text)
print("After removing all the vowels from the said string: " test(text))
text = "JavaScript"
print("\nOriginal string:",text)
print("After removing all the vowels from the said string: " test(text))
CodePudding user response:
You just need to modify the regular expression to have Russian vowels rather than English ones, something like:
return re.sub(r'[аэыоуяеиёю] ', '', text, flags=re.IGNORECASE)
Ditto for any other language you need to handle.