Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import re
  2. def has_pattern(string, regex):
  3. if string and re.compile(regex).search(string) is not None:
  4. return True
  5. return False
  6.  
  7. # for absolute path on windows
  8. pattern = '^[a-zA-Z]:\\[^\\]' # actual regex: [a-zA-Z]:\[^\]
  9. path = 'a:\' # for this result should be 'True'
  10. print('Pattern: '{0}''.format(pattern))
  11. print('Result: {0}'.format(has_pattern(path, pattern)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement