Reputation: 305
I have a string and want to match which has words, number, and forward slash. for eg my string is 'abc/11/xyz' I tried it but returns nothing,
re.match(r'(a-z)+/(\d)+/(\w)+', 'abc/11/xyz')
Thank you
Upvotes: 1
Views: 453
Reputation: 6441
re.match(r'([a-z])+/(\d)+/(\w)+', 'abc/11/xyz')
(a-z)+
matches literally a-z
. It seems you want to match any characters between a and z, so you need to use square brackets ([a-z])+
to make a character class.
Upvotes: 3