#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?=.{3,50}$)[^\s\d]*(\s[^\s\d]*)?$"
Local $sString = "I need a RegEx to match the following condition:" & @CRLF & _
"" & @CRLF & _
"1 or 2 words" & @CRLF & _
"Total minimum length is 3" & @CRLF & _
"Total maximum length is 50" & @CRLF & _
"Accept accented characters" & @CRLF & _
"No numbers is a plus" & @CRLF & _
"Examples of accepted strings: dfg dfg dfg sdfg dasfg " & @CRLF & _
"" & @CRLF & _
"Karmen Garcia" & @CRLF & _
"João Pedro" & @CRLF & _
"Vitor" & @CRLF & _
"maxiliamum Lófffffffffffffffffffffffffffffffffffff" & @CRLF & _
"Nadál" & @CRLF & _
"loriPsium PsisVõèrbizbbbbbbbbbb" & @CRLF & _
"Examples of non accepted string:" & @CRLF & _
"" & @CRLF & _
"Jony Cam Vanis" & @CRLF & _
"kljsdfklsdfkljsfkldsfkljs dsfkljsdlfldjsfkldjsfljsdlkfjls" & @CRLF & _
"sdlfkjsdklfjklsdfjkljsfjsdfljsdlfjsdfkljsdfkljsdlfkjlksf" & @CRLF & _
"9lucas P.us-kas1 Li1" & @CRLF & _
"What I tried:" & @CRLF & _
"" & @CRLF & _
"^(?!.*?\s{2})[A-Za-z ]{3,50}$" & @CRLF & _
"^([a-zA-Z][a-zA-Z]){3,50}$"
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