I have read the Google python regex tutorial about regular expression and tried to test one of the patterns I need.
- String must be 10 characters long.
- 1,3,5,7,9 chars must be digits (1 – 5) and should not be repeated
- other symbols are letters (a, b or c) and the can be repeated
For example:
1a2b4a3c5b # is valid
1a5c4b4a3b # is not valid because of two 4s
So far I’ve tried:
pattern = r'([1-5])[abc]([1-5^\1])[abc]([1-5^\1\2])[abc]([1-5\1\2\3])[abc]([1-5\1\2\3\4])[abc]'
but it failed…
I would suggest something like this instead of regex: