#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?i)(\w{2}).*?(\1)"
Local $sString = "This is a repeated repeated word.zz zz zz" & @CRLF & _
"" & @CRLF & _
"How would you find pairs of letters that occur twice in a string using regex with Python?" & @CRLF & _
"" & @CRLF & _
"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." & @CRLF & _
"" & @CRLF & _
"Ex:" & @CRLF & _
"this one has xx twice so I want to keep this string:" & @CRLF & _
"xxhgfhdeifhjfrikfoixx" & @CRLF & _
"" & @CRLF & _
"this one would be kept as well, because hd is repeated: " & @CRLF & _
"kwofhdbugktrkdidhdnbk" & @CRLF & _
"" & @CRLF & _
"The best I got was to find the pairs: ([a-z][a-z])\1|([a-z])\2" & @CRLF & _
"" & @CRLF & _
"I need to find which pairs repeat in the string."
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm