Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double letter matching using python regex

Tags:

python

regex

I am trying to find a way using regex to match words that have 3 unique sets of double letters. so far i have this:

r".*([a-z])\1.*([a-z])\2.*([a-z])\3.*"    

But that doesn't account for unique sets for double letters. Thanks in advance =)

like image 452
user2696287 Avatar asked Mar 26 '26 21:03

user2696287


1 Answers

Maybe like this? Seems to work for me.

r".*([a-z])\1.*((?=(?!\1))[a-z])\2.*((?=(?!\1))(?=(?!\2))[a-z])\3.*"

(?=expr) is a non-consuming regular expression, and (?!expr) is regex NOT operator.

like image 57
Tigran Saluev Avatar answered Mar 29 '26 09:03

Tigran Saluev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!