#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)\&?"
Local $sString = "http://www.youtube.com/watch?v=iwGFalTRHDA" & @CRLF & _
"http://www.youtube.com/watch?v=iwGFalTRHDA" & @CRLF & _
"http://youtu.be/embed/iwGFalTRHDA" & @CRLF & _
"http://youtu.be/n17B_uFF4cA" & @CRLF & _
"http://www.youtube.com/embed/iwGFalTRHDA" & @CRLF & _
"http://youtu.be/t-ZRX8984sc" & @CRLF & _
"https://www.youtube.com/embed/UIpuNuV23v0"
Local $sSubst = "$0/modestbranding=1&rel=0"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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