#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^/(media/catalog/product/cache)/\d+/thumbnail/(\d+x\d+)/[a-z0-9]+/(\S+)"
Local $sString = "/media/catalog/product/cache/1/thumbnail/543x403/db978388cfd007780066eaab38556cef/l/e/legal_slide01.jpg" & @CRLF & _
"# check if match with above:" & @CRLF & _
"/pub/media/catalog/product/cache/543x403/l/e/legal_slide01.jpg" & @CRLF & _
"" & @CRLF & _
"/media/catalog/product/cache/1/thumbnail/543x403/db978388cfd007780066eaab38556cef/n/u/number1.png" & @CRLF & _
"# check if match with above:" & @CRLF & _
"/pub/media/catalog/product/cache/543x403/n/u/number1.png"
Local $sSubst = "/pub/$1/$2/$3"
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