#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?i)(?<scheme>http|https|ftp|sftp|sip|sips|file):\/\/(?:(?<username>[^`!@#$^&*()+=,:;'"{}\|\[\]\s\/\\]+)(?::(?<password>[^`!@#$^&*()+=,:;'"{}\|\[\]\s\/\\]+))?@)?(?:(?<ipv4>((?:(?:25[0-5]|2[0-4]\d|1?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1?\d\d?)))|\[(?<ipv6>(?i)(?:[\da-f]{0,4}:){1,7}(?:(?<ipv4_in_ipv6>(?:(?:25[0-5]|2[0-4]\d|1?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1?\d\d?))|[\da-f]{0,4}))\]|(?:(?<sub_domain>[^\s~`!@#$%^&*()_+=,.?:;'"{}\|\[\]\/\\]+\.)*(?<domain>[^\s~`!@#$%^&*()_+=,.?:;'"{}\|\[\]\/\\]+)(?<tld>\.[^\s~`!@#$%^&*()\-_+=,.?:;'"{}\|\[\]\/\\0-9]{2,})))+(?<port>:\d+)?(?:\/(?<path>\/?[^\s`@#$^&=.?"{}\\]+\/)*(?<file>[^\s`@#$^&=?"{}\/\\]+)?(?<query>\?[^\s`#$^"{}\\]+)*(?<fragment>#[^\s`$^&=?"{}\/\\]+)?)?"
Local $sString = "# Quick Example (full)" & @CRLF & _
"https://uSer:pass@sub1.sub-2.EXamPle.uk.com:80/PATH1/paTh2?qUeRy=1&q2=2#ancHor" & @CRLF & _
"https://úser@suß.öctúvt.tìd/file-path/FILE_%82%8A.php?query=value&query2=value2#somethig" & @CRLF & _
"HTTP://دامنه.ایران/زیردامنه/زیردامنه۲/فایل.پسوند؟درخواست=جواب" & @CRLF & _
"http://blog.sergeys.us/beer?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+SergeySus+(Sergey+Sus+Photography+%C2%BB+Blog)&utm_content=Google+Reader" & @CRLF & _
"http://test.site/wp-admin/post.php?t=1347548645469?t=1347548651124?t=1347548656685?t=1347548662469?t=1347548672300?t=1347548681615?#sdfsdf" & @CRLF & _
"http://example.com/wp-admin/load-scripts.php?c=1&load[]=swfobject,jquery,utils&ver=3.5" & @CRLF & _
"http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#hello" & @CRLF & _
"https://example.com/path/resource.txt#fragment" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"# Basic" & @CRLF & _
"www.example.com" & @CRLF & _
"http://example.com" & @CRLF & _
"https://example.com" & @CRLF & _
"https://example.ac.eu" & @CRLF & _
"https://example.gov.ir" & @CRLF & _
"ftp://example.com" & @CRLF & _
"sftp://example.com" & @CRLF & _
"" & @CRLF & _
"# With Path" & @CRLF & _
"www.example.com/path1/path2/" & @CRLF & _
"http://example.com/path1/path2/" & @CRLF & _
"https://example.com/path1/path2" & @CRLF & _
"" & @CRLF & _
"# With Path & File" & @CRLF & _
"www.example.com/path1/path2/file.pdf" & @CRLF & _
"http://example.com/path1/path2/file.c" & @CRLF & _
"https://example.com/path1/path2/file.txt" & @CRLF & _
"" & @CRLF & _
"# With Path & Query" & @CRLF & _
"http://www.example.com/?query=some-path/path1/path2/" & @CRLF & _
"http://example.com/path1/path2/?query=something" & @CRLF & _
"https://example.com/path1/path2?query=something" & @CRLF & _
"" & @CRLF & _
"# With Subdomain" & @CRLF & _
"sub1.sub2.example.com" & @CRLF & _
"www.example.com" & @CRLF & _
"http://www.example.com" & @CRLF & _
"ftp://sub1.example.com" & @CRLF & _
"" & @CRLF & _
"# With Port" & @CRLF & _
"www.example.com:80" & @CRLF & _
"http://example.com:8080" & @CRLF & _
"ftp://example.com:21" & @CRLF & _
"ftp://sub1.example.com:21" & @CRLF & _
"http://example.com:8080/path1/path2/" & @CRLF & _
"http://example.com:80/path1/path2/file.c" & @CRLF & _
"http://example.com:443/path1/path2/?query=something" & @CRLF & _
"" & @CRLF & _
"# With Username" & @CRLF & _
"user@example.com" & @CRLF & _
"http://user@www.example.com" & @CRLF & _
"ftp://user@example.com" & @CRLF & _
"ftp://user@sub1.example.com:21" & @CRLF & _
"http://user@example.com:8080/path1/path2/" & @CRLF & _
"http://user@example.com/path1/path2/file.c" & @CRLF & _
"http://user@example.com/path1/path2/?query=something" & @CRLF & _
"" & @CRLF & _
"# Some Crazy Examples" & @CRLF & _
"http://ヒキワリ.ナットウ.ニホン" & @CRLF & _
"sip://ßàÁâãóôþüúðæåïçèõöÿýòäœêëìíøù.îûñé" & @CRLF & _
"HTTP://دامنه.ایران/زیردامنه/زیردامنه۲/فایل.پسوند؟درخواست=جواب" & @CRLF & _
"http://example.com/wp-admin/load-scripts.php?c=1&load[]=swfobject,jquery,utils&ver=3.5" & @CRLF & _
"https://úser@sub1.suß2.sub3.öctúvt.tìd.tìd/V3/file-path/P----29BSx_A_%82%8A_D_M1n_a.php?query=value#somethig" & @CRLF & _
"http://www.go.com.au/ersdfs?dfd=dfgd@s=1" & @CRLF & _
"https://uSer@EXamPle.uk.com:80/?qyery?qUeRy=1&q2=2#ancHor" & @CRLF & _
"http://example.com/%E5%BC%95%E3%81%8D%E5%89%B2%E3%82%8A.html" & @CRLF & _
"hTTp://eXamPLE.CoM" & @CRLF & _
"https://belgië.be" & @CRLF & _
"https://belgië.be.gov" & @CRLF & _
"http://user@[2001:db8::1]/" & @CRLF & _
"https://user@111.222.33.44:49171/Cda-cgi/clientcgi?action=start" & @CRLF & _
"http://[2001:db8::1]:80" & @CRLF & _
"a2d.dd4d.d5d.www.go.com.au" & @CRLF & _
"a.b.c.d.e.go.com.co.uk" & @CRLF & _
"go.com.uk" & @CRLF & _
"go.go.com" & @CRLF & _
"1go-co.com" & @CRLF & _
"1-2-3-4--5-go.com" & @CRLF & _
"www.go.com.au" & @CRLF & _
"" & @CRLF & _
"# These Should not be Seen as Domain" & @CRLF & _
"example.c" & @CRLF & _
"example..com" & @CRLF & _
"123.b" & @CRLF & _
"go.12" & @CRLF & _
"1.2.3.4" & @CRLF & _
"ff:ff:ff:ff" & @CRLF & _
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" & @CRLF & _
"hTTps://111.222.533.44:49171/cda-cgi/clientcgi?action=start" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"# These Should be Seen Partially" & @CRLF & _
"//example.com.c" & @CRLF & _
"example.com.c" & @CRLF & _
"http://example.com.com." & @CRLF & _
"" & @CRLF & _
"# It Should Find URLs in a Text too" & @CRLF & _
"create Share Links to send your expressions to co-workers or link to them on Twitter or your blog [ex. http://RegExr.com?2rjl655] " & @CRLF & _
"Built by gskinner.com with Flex 3 [adobe.com/go/flex] and Spelling Plus Library for text highlighting[gskinner.com/products/spl]." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"# Resources" & @CRLF & _
"- https://en.wikipedia.org/wiki/Uniform_Resource_Identifie" & @CRLF & _
"- https://en.wikipedia.org/wiki/List_of_URI_schemes" & @CRLF & _
"- " & @CRLF & _
"- https://zencoder.support.brightcove.com/general-information/special-characters-usernames-and-passwords.html" & @CRLF & _
"- https://support.microsoft.com/en-us/topic/certain-special-characters-are-not-allowed-in-the-url-entered-into-the-address-bar-of-internet-explorer-a8e2a966-19d6-27af-06cc-e720f25e8b02" & @CRLF & _
"- https://perishablepress.com/stop-using-unsafe-characters-in-urls/" & @CRLF & _
"- https://help.dragonmetrics.com/en/articles/213986-invalid-characters-in-url"
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