def getConfNum(msgText):
# get the confirmation number
if 'confNum=' in msgText:
strIndexStart = msgText.find('confNum=')+8
strIndexEnd = strIndexStart+6
confNum = str(msgText[strIndexStart:strIndexEnd])
else:
# get dictionary
d = enchant.Dict("en_US")
pattern = re.compile(r'(?<![A-Za-z0-9])[A-Z0-9]{6}(?![A-Za-z0-9])')
msgTextConfNumSearch = msgText[200:]
regExSearch = pattern.search(msgTextConfNumSearch)
while regExSearch:
# see if the found string is a real word
possibleConfNum = regExSearch.group()
if not d.check(possibleConfNum):
confNum = str(possibleConfNum)
break
else:
msgTextConfNumSearch = msgTextConfNumSearch[regExSearch.end():]
regExSearch = pattern.search(msgTextConfNumSearch)
return confNum
评论列表
文章目录