#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^.*(youtu.be\/|v\/|u\/\w+\/|embed|e\/|watch\?v|\?v=|\&v=)([^#\&\?]{11,11}).*"
Local $sString = "http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0" & @CRLF & _
"http://www.youtube.com/embed/0zM3nApSvMg?rel=0" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg" & @CRLF & _
"http://youtu.be/0zM3nApSvMg" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" & @CRLF & _
"http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/KdwsulMb8EQ" & @CRLF & _
"http://www.youtube.com/user/IngridMichaelsonVEVO#p/u/11/KdwsulMb8EQ" & @CRLF & _
"http://youtu.be/dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/embed/dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/v/dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/e/dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/watch?v=dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/?v=dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ" & @CRLF & _
"http://www.youtube-nocookie.com/v/6L3ZvIMwZFM?version=3&hl=en_US&rel=0"
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