#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:(?:https?:\/\/)?(?:(?:www|s|i2)\.)?(?:youtu\.?be|ytimg)(?:\.com)?\/)(?:watch\?v=|v\/|yt\/favicon|oembed\?|vi\/)?(?:url=http%3A\/\/www\.youtube\.com\/watch\?v%3D)?([a-zA-Z0-9_-]*).*?$"
Local $sString = "https://www.youtube.com/watch?v=Gge6Hg2-RVM" & @CRLF & _
"" & @CRLF & _
"http://www.youtube.com/watch?v=-wtIMTCHWuI" & @CRLF & _
"" & @CRLF & _
"http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1" & @CRLF & _
"" & @CRLF & _
"http://youtu.be/-wtIMTCHWuI" & @CRLF & _
"" & @CRLF & _
"http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json" & @CRLF & _
"" & @CRLF & _
"http://s.ytimg.com/yt/favicon-wtIMTCHWuI.ico" & @CRLF & _
"" & @CRLF & _
"http://i2.ytimg.com/vi/-wtIMTCHWuI/hqdefault.jpg"
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