Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(\w{2}).*?(\1)
/
gi
Input 1
1
New
This is a repeated repeated word.zz zz zz How would you find pairs of letters that occur twice in a string using regex with Python? I want to iterate through a list of strings, find the ones that have repeating pairs of letters, and put them into a list. The letters don't need to be the same, the pair just has to repeat, though the letters can be the same. Ex: this one has xx twice so I want to keep this string: xxhgfhdeifhjfrikfoixx this one would be kept as well, because hd is repeated: kwofhdbugktrkdidhdnbk The best I got was to find the pairs: ([a-z][a-z])\1|([a-z])\2 I need to find which pairs repeat in the string.
Substitution