Advertisement
Guest User

Untitled

a guest
Nov 10th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import re
  2. RE_VERSION_NAME_PREFIX = "([sS]pring)"
  3. RE_VERSION_MAJOR_PATCH = "([0-9]+\.[0-9]+[\.0-9]*)"
  4. RE_VERSION_COMMIT_HASH = "(?:-)?(?:([0-9]+-g[0-9a-f]+)"
  5. RE_VERSION_BRANCH_NAME = "([a-zA-Z0-9\-]+))?"
  6. RE_VERSION =                          \
  7.         RE_VERSION_NAME_PREFIX + " ?" + \
  8.         RE_VERSION_MAJOR_PATCH + " ?" + \
  9.         RE_VERSION_COMMIT_HASH + " ?" + \
  10.         RE_VERSION_BRANCH_NAME
  11.  
  12. RE_OLD_VERSION = r'Spring [^\(]+ \(([^\)]+)\{\@\}-cmake-mingw32\)[\w\(\) ]*'
  13.  
  14. teststrings = [
  15.     "Spring 83.0",
  16.     "Spring 83.0 has crashed",
  17.     "Spring 83.0.1-67-g714836f develop (Debug)",
  18.     ]
  19.  
  20. def test(regex, string):
  21.     res=re.match(regex, string)
  22.     if res:
  23.         print "regex: %s"%(regex)
  24.         print "group: %s groups: %s" %(res.group(), res.groups())
  25.  
  26. for string in teststrings:
  27.     test(RE_VERSION, string)
  28.     test(RE_OLD_VERSION, string)
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement