#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*"
Local $sString = "https://youtu.be/embed/n-WuWyZPcoE" & @CRLF & _
"https://youtube.com/embed/n-WuWyZPcoE" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" & @CRLF & _
"http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/QdK8U-VIH_o" & @CRLF & _
"http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s" & @CRLF & _
"http://www.youtube.com/embed/0zM3nApSvMg?rel=0" & @CRLF & _
"http://www.youtube.com/watch?v=0zM3nApSvMg" & @CRLF & _
"http://youtu.be/0zM3nApSvMg" & @CRLF & _
""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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