#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?:(?:https?\:\/\/)?(?:www\.)?(?:youtube|youtu)(?:(?:\.com|\.be)\/)(?:embed\/)?(?:watch\?)?(?:feature=player_embedded)?&?(?:v=)?([0-z]{11}|[0-z]{4}(?:\-|\_)[0-z]{4}|.(?:\-|\_)[0-z]{9}))"
Local $sString = "http://youtube.com/watch?v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/watch?v=iwGFalTRHDA&feature=related" & @CRLF & _
"https://youtube.com/iwGFalTRHDA" & @CRLF & _
"http://youtu.be/n17B_uFF4cA" & @CRLF & _
"youtube.com/iwGFalTRHDA" & @CRLF & _
"youtube.com/n17B_uFF4cA" & @CRLF & _
"http://www.youtube.com/embed/watch?feature=player_embedded&v=r5nB9u4jjy4" & @CRLF & _
"http://www.youtube.com/watch?v=t-ZRX8984sc" & @CRLF & _
"http://youtu.be/t-ZRX8984sc" & @CRLF & _
"http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US" & @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