diff --git a/versionhandler.py b/versionhandler.py index 6c35df9..8a4e376 100644 --- a/versionhandler.py +++ b/versionhandler.py @@ -22,7 +22,7 @@ def extract_version( """ # Remove a prefix of the name of the program if existent if name: - namere = re.compile(r"^" + re.escape(name) + r"[ -_]", re.IGNORECASE) + namere = re.compile(r"^" + re.escape(name) + r"[ _-]", re.IGNORECASE) match = namere.match(string) if match: string = string[match.end() :] @@ -35,7 +35,7 @@ def extract_version( stable = re.compile(r"(\s|^|v)(\d{1,3}(\.\d{1,3})+(-\d\d?|[a-z])?)(\s|$)", re.IGNORECASE) pre = re.compile( - r"(\s|^|v)((\d{1,3}(\.\d{1,3})+)[.-]?(alpha|beta|pre|rc|b|preview)[.-]?\d*)(\s|$)", + r"(\s|^|v)((\d{1,3}(\.\d{1,3})+)[._-]?(alpha|beta|pre|rc|b|preview)[._-]?\d*)(\s|$)", re.IGNORECASE, ) explicitstable = re.compile( diff --git a/versionhandler_test.py b/versionhandler_test.py index 7eeb4d9..39bb0d3 100644 --- a/versionhandler_test.py +++ b/versionhandler_test.py @@ -35,6 +35,8 @@ def test_unstable(): assert extract_version("1.3b1") == ("beta", "1.3b1") assert extract_version("Picard 2.0.0beta3") == ("beta", "2.0.0beta3") assert extract_version("v1.0.0-beta3") == ("beta", "1.0.0-beta3") + assert extract_version("9.3.2_RC1") == ("rc", "9.3.2_RC1") + assert extract_version("v2.1-rc1") == ("rc", "2.1-rc1") def test_invalid(): @@ -54,3 +56,4 @@ def test_invalid(): assert extract_version("foo #871") is None assert extract_version("RC1") is None assert extract_version("1234567") is None + assert extract_version("mame0199", "mame") is None