Q: regex to normalize these spellings in python I need your guidance to make this code worked properly.When I run it, it returns all the modified words but some parts are missing. Example turn u, when u comes before a vowel into v in the following words gouuernement, reuestu, gouuvernez,etc it returns vernement,vestu,vernez instead of gouvernement, revestu,gouvernez....Also in the re.compile method I would like to include a list of words that the modification does not involve. Dear users, please a newbie needs your help to solve issues in regex.
import re, string, unicodedata
import spacy
import codecs
import io
nlp = spacy.load('fr')
with codecs.open(r'/home/fatkab/RD/rule6output.txt', encoding='utf8')as f6:
  word6 =f6.read()
sub_pattern6= re.compile(r"\b[a-zA-Z]+[aieuo]+u([aieuo]+[a-zA-Z]+\b)")#turn u to v in words such as seruitude, gouuernement ,renouueller ...
print(re.sub(sub_pattern6, r"v\1", word6))


A: If your intention is only to replace a character( here 'u') with another character ( here 'v'), then you can do it by: 
with open('path/to/your/file.txt', 'r+') as f:
    file_str = f.read()
    print(file_str)
    file_str = file_str.replace('u','v') # replacing the file str
    print(file_str) # later you can write this variable to the file itself

hope that helps.
