#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(postgresql|postgres):\/\/([^:@\s]*(?::[^@\s]*)?@)?(?<server>[^\/\?\s]+)\b"
Local $sString = "postgresql://localhost" & @CRLF & _
"postgresql://localhost:5433" & @CRLF & _
"postgresql://localhost/mydb" & @CRLF & _
"postgresql://user@localhost" & @CRLF & _
"postgresql://user:secret@localhost" & @CRLF & _
"postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp" & @CRLF & _
"postgresql://host1:123,host2:456/somedb?application_name=myapp" & @CRLF & _
"postgres://myuser:mypassword@192.168.0.100:5432/mydatabase" & @CRLF & _
"postgresql://192.168.0.100/mydb" & @CRLF & _
"" & @CRLF & _
"" & @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