#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w-_]+)"
Local $sString = "http://www.youtube.com/watch?v=iwGFalTRHDA " & @CRLF & _
"https://www.youtube.com/watch?v=iwGFalTRHDA " & @CRLF & _
"http://www.youtube.com/watch?v=iwGFalTRHDA&feature=related " & @CRLF & _
"http://youtu.be/iwGFalTRHDA " & @CRLF & _
"http://www.youtube.com/embed/watch?feature=player_embedded&v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/embed/watch?v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/embed/v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/watch?feature=player_embedded&v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/watch?v=iwGFalTRHDA" & @CRLF & _
"www.youtube.com/watch?v=iwGFalTRHDA " & @CRLF & _
"www.youtu.be/iwGFalTRHDA " & @CRLF & _
"youtu.be/iwGFalTRHDA " & @CRLF & _
"youtube.com/watch?v=iwGFalTRHDA " & @CRLF & _
"http://www.youtube.com/watch/iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/v/iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/v/i_GFalTRHDA" & @CRLF & _
"http://www.youtube.com/watch?v=i-GFalTRHDA&feature=related " & @CRLF & _
"http://www.youtube.com/attribution_link?u=/watch?v=aGmiw_rrNxk&feature=share&a=9QlmP1yvjcllp0h3l0NwuA" & @CRLF & _
"http://www.youtube.com/attribution_link?a=fF1CWYwxCQ4&u=/watch?v=qYr8opTPSaQ&feature=em-uploademail" & @CRLF & _
"http://www.youtube.com/attribution_link?a=fF1CWYwxCQ4&feature=em-uploademail&u=/watch?v=qYr8opTPSaQ"
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