#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mix)(.*) ((youtube.com) | (youtu.be) | (www.youtube.com) ) (.*)"
Local $sString = "http://youtu.be/cCnrX1w5luM" & @CRLF & _
"www.youtube.com/cCnrX1w5luM " & @CRLF & _
"youtu.be/cCnrX1w5luM" & @CRLF & _
"https://www.youtube.com/watch?v=nzj7Wg4DAbs" & @CRLF & _
"http://www.youtube.com/watch?v=nzj7Wg4DAbs" & @CRLF & _
"youtube.com/watch?v=nzj7Wg4DAbs" & @CRLF & _
"http://www.youtube.com/watch?v=-wtIMTCHWuI" & @CRLF & _
"http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1" & @CRLF & _
"http://youtu.be/-wtIMTCHWuI" & @CRLF & _
"http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json" & @CRLF & _
"Hello https://www.youtube.com/watch?v=nzj7Wg4DAbs world" & @CRLF & _
""
Local $sSubst = "<iframe src="htpp://youtube.com$6" allowfullscreen></frame>"
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