Reputation: 911
I'm using regex to find occurrences in a string python, for example: "cw cx", "cw cx av", "cw cx dr wt" or "cw cx qw hv eb". The match can be 2, 3, 4 or 5 pairs. I'm thinking something like this "([a-zA-Z]{2}) ([a-zA-Z]{2})" Please help me
Upvotes: 2
Views: 160
Reputation: 785631
You can use this regex:
\b[a-zA-Z]{2}(?: [a-zA-Z]{2}){1,4}\b
Upvotes: 1