Applied a patch from dkg@fifthhorseman.net: Fix regex manipulation for word characters.
in python 3.7, re.sub() started treating unknown escape sequences in as errors. Fix this by sending an escaped \ where we mean to pass it through raw. https://docs.python.org/3/library/re.html#re.sub - Legacy-Id: 15892
This commit is contained in:
parent
e39358312b
commit
c8f98e125c
|
@ -554,9 +554,9 @@ class Draft():
|
|||
|
||||
def make_authpat(hon, first, last, suffix):
|
||||
def dotexp(s):
|
||||
s = re.sub(r"\. ", r"\w* ", s)
|
||||
s = re.sub(r"\.$", r"\w*", s)
|
||||
s = re.sub(r"\.(\w)", r"\w* \1", s)
|
||||
s = re.sub(r"\. ", r"\\w* ", s)
|
||||
s = re.sub(r"\.$", r"\\w*", s)
|
||||
s = re.sub(r"\.(\w)", r"\\w* \1", s)
|
||||
return s
|
||||
first = dotexp(first)
|
||||
last = dotexp(last)
|
||||
|
@ -572,7 +572,7 @@ class Draft():
|
|||
|
||||
# Some chinese names are shown with double-letter(latin) abbreviated given names, rather than
|
||||
# a single-letter(latin) abbreviation:
|
||||
first = re.sub(r"^([A-Z])[A-Z]+\\w\*", r"\1[-\w]+", first)
|
||||
first = re.sub(r"^([A-Z])[A-Z]+\\w\*", r"\1[-\\w]+", first)
|
||||
|
||||
# permit insertion of middle names between first and last, and
|
||||
# add possible honorific and suffix information
|
||||
|
|
Loading…
Reference in a new issue