#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(https?:\/\/)?(www\.)?(\S+)(\.[^\s\/]+)(\/\S*)?"
Local $sString = "https://www.google.com" & @CRLF & _
"http://coreyms.com" & @CRLF & _
"https://www.youtube.com/watch?v=sa-TUpSx1JA" & @CRLF & _
"https://www.nasa.gov" & @CRLF & _
"www.desmos.com" & @CRLF & _
"pastebin.com/s8fh3HAs" & @CRLF & _
"https://www.regex101.com/" & @CRLF & _
"www.translate.google.com/" & @CRLF & _
"https://roblox.com/home" & @CRLF & _
"chat.openai.com/?model=text-davinci-002-render-sha" & @CRLF & _
"https://www.amazon.com/" & @CRLF & _
"agar.io/#ffa"
Local $sSubst = "$3$4"
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