#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?:(href|src).+?[\w\-\s]{30,}")"
Local $sString = "What I'm looking to do:" & @CRLF & _
"Regex should only confirm a match if it identifies at least 4 URLs with long strings. My current pattern is:" & @CRLF & _
"/(?:(href|src).+?[\w\-\s]{30,}")/g" & @CRLF & _
"This pattern detects all six matches shown below, but even if only one match was present it would still return that match. I want it to return "no match" if there aren't at least 4 present, and note that since each URL has a DIFFERENT long string, I can't use {4,}? as it only works if it finds 4 instances of the same thing." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"___MATCH ONE___" & @CRLF & _
"<body><a href="http://keyslinte.us/ayMxQdN567OeuL6MbKxQ4MtGvL-TLr_DqZJs3ZP1eFs"><img border="0" " & @CRLF & _
"" & @CRLF & _
"___MATCH TWO___" & @CRLF & _
"src="http://keyslinte.us/UHJo_e_vTeHGuwu-U-fdLOl_c0KUCZEG2TEDKCTVjg" " & @CRLF & _
"" & @CRLF & _
"___MATCH THREE___" & @CRLF & _
" <p align="left"><a href="http://keyslinte.us/LO0GUD" & @CRLF & _
"U9uxlR7CyPiNBIWLf3dU0eWVZ872lF8Gus8Q"><img " & @CRLF & _
"" & @CRLF & _
"___MATCH FOUR___" & @CRLF & _
"href="http://keyslinte.us/LO0GUDU9uxlR7CyPiNBIWLf3dU0eWVZ872lF8Gus8Q"" & @CRLF & _
"" & @CRLF & _
"___MATCH FIVE___" & @CRLF & _
"href="http://keyslinte.us/EkpR4EpSAdBmRvPT32X8bgQW2ywXo3XnK5-xIIe3vA" " & @CRLF & _
"" & @CRLF & _
"___MATCH SIX___" & @CRLF & _
"<p align="left"><a href="http://keyslinte.us/B-OPTRjhR6t388ah5NMUHoSPAjN1LENnJRoEurIXIQ"><img " & @CRLF & _
"" & @CRLF & _
""
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