add regex;

This commit is contained in:
Chrys
2019-10-22 00:45:38 +02:00
parent aa5bb94237
commit 981bf85cf0
7 changed files with 137 additions and 130 deletions

View File

@ -39,9 +39,12 @@ class punctuationManager():
if customDict:
for key,item in customDict.items():
try:
resultText = re.sub(str(key), seperator + str(item) + seperator, resultText)
except:
resultText = resultText.replace(str(key),seperator + str(item) + seperator)
if item.upper().startswith('REGEX;') and (len(item) > 6):
resultText = re.sub(str(key), seperator + str(item[6:]) + seperator, resultText)
else:
resultText = resultText.replace(str(key),seperator + str(item) + seperator)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut("useCustomDict replace:'" + key + "' with '" + item +"' failed:" + str(e),debug.debugLevel.ERROR, onAnyLevel=False)
return resultText
def usePunctuationDict(self, text, punctuationDict, punctuation):
resultText = str(text)