I think I figure out how to make the regex work with the WordDictionary...
I test it with 4-5 words epub that I intentionally misspelled and it work. But i'm gonna test it some more times first in a full epub!
@CalibUser is the code correct?
Code:
def FixP(m):
"""
This function examines a word to see whether is required to fix the Π character that is misspelled.
It is called by a regular expression function (re.sub) in FixCommonErrors()
It returns the original expression if the checked word is not in the dictionary,
otherwise it returns the word without the Π fixed
"""
FixP='Π'+m.group(2)
if spell(FixP):
print("FixP removed from: ", FixP)
return(FixP)
else:
return(m.group(0))
#Fixes Π in words that are misspelled
if dictExists == True:
CorrectText("Π fixes",r"(ΓΙ|Γΐ|ΙΙ|II|I\ I|I\ Ι|ΓΤ|ΙΊ|Ιί)[ ]?(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", FixP)
Thanks