From 55593c3ef530ea01b1cfb1f7c81ee34fd994d0ef Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 26 Sep 2004 18:56:44 +0000 Subject: [PATCH] Make the regex pattern easier to read, understand, and modify by factoring out the common prefix (the delimiter). --- Lib/string.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/string.py b/Lib/string.py index 623eb0edab..7371c915a1 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -101,10 +101,12 @@ class _multimap: class _TemplateMetaclass(type): pattern = r""" - (?P%(delim)s{2}) | # Escape sequence of two delimiters - %(delim)s(?P%(id)s) | # delimiter and a Python identifier - %(delim)s{(?P%(id)s)} | # delimiter and a braced identifier - (?P%(delim)s) # Other ill-formed delimiter exprs + %(delim)s(?: + (?P%(delim)s) | # Escape sequence of two delimiters + (?P%(id)s) | # delimiter and a Python identifier + {(?P%(id)s)} | # delimiter and a braced identifier + (?P) # Other ill-formed delimiter exprs + ) """ def __init__(cls, name, bases, dct): -- 2.40.0