Skip to content

Commit 34d6a86

Browse files
committed
tweak capitalization of mac regex to fix "mack", fixes #56
1 parent e7ffbca commit 34d6a86

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

nameparser/config/regexes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
REGEXES = set([
2222
("spaces", re.compile(r"\s+", re.U)),
2323
("word", re.compile(r"(\w|\.)+", re.U)),
24-
("mac", re.compile(r'^(ma?c)(\w+)', re.I | re.U)),
24+
("mac", re.compile(r'^(ma?c)(\w{2,})', re.I | re.U)),
2525
("initial", re.compile(r'^(\w\.|[A-Z])?$', re.U)),
2626
("nickname", re.compile(r'\s*?[\("](.+?)[\)"]', re.U)),
2727
("roman_numeral", re.compile(r'^(X|IX|IV|V?I{0,3})$', re.I | re.U)),

tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,10 @@ def test_downcasing_mc(self):
18581858
hn.capitalize()
18591859
self.m(str(hn), 'Ronald McDonald', hn)
18601860

1861+
def test_short_names_with_mac(self):
1862+
hn = HumanName('mack johnson')
1863+
hn.capitalize()
1864+
self.m(str(hn), 'Mack Johnson', hn)
18611865

18621866
class HumanNameOutputFormatTests(HumanNameTestBase):
18631867

0 commit comments

Comments
 (0)