avoid duplicate pattern groups

Since patterns are always wrapped in a named group anyway,
we don't need to do another unnamed group also. This makes
the regular expressions more readable.
This commit is contained in:
Manuel Barkhau 2020-10-03 18:04:08 +00:00
parent 4c8c9b128a
commit 2f421daf16
2 changed files with 31 additions and 25 deletions

View file

@ -64,27 +64,27 @@ PART_PATTERNS = {
'GG' : r"[1-9][0-9]?",
'0G' : r"[0-9]{2}",
'Q' : r"[1-4]",
'MM' : r"(?:1[0-2]|[1-9])",
'0M' : r"(?:1[0-2]|0[1-9])",
'DD' : r"(?:3[0-1]|[1-2][0-9]|[1-9])",
'0D' : r"(?:3[0-1]|[1-2][0-9]|0[1-9])",
'JJJ' : r"(?:36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9])",
'00J' : r"(?:36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|0[1-9][0-9]|00[1-9])",
'MM' : r"1[0-2]|[1-9]",
'0M' : r"1[0-2]|0[1-9]",
'DD' : r"3[0-1]|[1-2][0-9]|[1-9]",
'0D' : r"3[0-1]|[1-2][0-9]|0[1-9]",
'JJJ' : r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]",
'00J' : r"36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|0[1-9][0-9]|00[1-9]",
# week numbering parts
'WW': r"(?:5[0-2]|[1-4][0-9]|[0-9])",
'0W': r"(?:5[0-2]|[0-4][0-9])",
'UU': r"(?:5[0-2]|[1-4][0-9]|[0-9])",
'0U': r"(?:5[0-2]|[0-4][0-9])",
'VV': r"(?:5[0-3]|[1-4][0-9]|[1-9])",
'0V': r"(?:5[0-3]|[1-4][0-9]|0[1-9])",
'WW': r"5[0-2]|[1-4][0-9]|[0-9]",
'0W': r"5[0-2]|[0-4][0-9]",
'UU': r"5[0-2]|[1-4][0-9]|[0-9]",
'0U': r"5[0-2]|[0-4][0-9]",
'VV': r"5[0-3]|[1-4][0-9]|[1-9]",
'0V': r"5[0-3]|[1-4][0-9]|0[1-9]",
# non calver parts
'MAJOR' : r"[0-9]+",
'MINOR' : r"[0-9]+",
'PATCH' : r"[0-9]+",
'BUILD' : r"[0-9]+",
'BLD' : r"[1-9][0-9]*",
'RELEASE': r"(?:preview|final|alpha|beta|post|pre|dev|rc|a|b|c|r)",
'PYTAG' : r"(?:post|dev|rc|a|b)",
'RELEASE': r"preview|final|alpha|beta|post|rc",
'PYTAG' : r"post|rc|a|b",
'NUM' : r"[0-9]+",
}