Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- RE_VERSION_NAME_PREFIX = "([sS]pring)"
- RE_VERSION_MAJOR_PATCH = "([0-9]+\.[0-9]+[\.0-9]*)"
- RE_VERSION_COMMIT_HASH = "(?:-)?(?:([0-9]+-g[0-9a-f]+)"
- RE_VERSION_BRANCH_NAME = "([a-zA-Z0-9\-]+))?"
- RE_VERSION = \
- RE_VERSION_NAME_PREFIX + " ?" + \
- RE_VERSION_MAJOR_PATCH + " ?" + \
- RE_VERSION_COMMIT_HASH + " ?" + \
- RE_VERSION_BRANCH_NAME
- RE_OLD_VERSION = r'Spring [^\(]+ \(([^\)]+)\{\@\}-cmake-mingw32\)[\w\(\) ]*'
- teststrings = [
- "Spring 83.0",
- "Spring 83.0 has crashed",
- "Spring 83.0.1-67-g714836f develop (Debug)",
- ]
- def test(regex, string):
- res=re.match(regex, string)
- if res:
- print "regex: %s"%(regex)
- print "group: %s groups: %s" %(res.group(), res.groups())
- for string in teststrings:
- test(RE_VERSION, string)
- test(RE_OLD_VERSION, string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement