Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def has_pattern(string, regex):
- if string and re.compile(regex).search(string) is not None:
- return True
- return False
- # for absolute path on windows
- pattern = '^[a-zA-Z]:\\[^\\]' # actual regex: [a-zA-Z]:\[^\]
- path = 'a:\' # for this result should be 'True'
- print('Pattern: '{0}''.format(pattern))
- print('Result: {0}'.format(has_pattern(path, pattern)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement