#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)(\|\s*(logo|image|screenshot|race_logo|track map)\s*=\s*)(File:|Image:)?([^\[\||<\n]*)((\|\s*\d{1,4}px(\?)?|\|\s*thumb))((\|\s*\d{1,4}px(\?)?|\|\s*thumb))?(?(?=\|[A-z]*\s*=)|(?(?=\|(\w*\W*)*)(\|[^\|\n]*)?)?)"
Local $sString = "| image = [[File:Central Asia (orthographic projection).svg|200px|Map of Central Asia]]" & @CRLF & _
"" & @CRLF & _
"|Image=|150px? " & @CRLF & _
"" & @CRLF & _
"}}]] – [[Template:POTD/2012-06-09|{{POTD texttitle" & @CRLF & _
"|image=Jack-in-cube solid model, light background.gif" & @CRLF & _
"|thumb=Jack-in-cube solid model, light background frame.png" & @CRLF & _
"|size=180" & @CRLF & _
"" & @CRLF & _
"|name = Reggae" & @CRLF & _
"| Image = File:Bob-Marley.jpg|thumb|231px|" & @CRLF & _
"| caption = Popular reggae artist [[Bob Marley]] in 1980" & @CRLF & _
"" & @CRLF & _
"{{Infobox officeholder" & @CRLF & _
"|image = Karenskiy AF 1917.jpg|230px" & @CRLF & _
"|nationality = Russian" & @CRLF & _
"" & @CRLF & _
"{{Infobox officeholder" & @CRLF & _
"|image = Karenskiy AF 1917.jpg|230px|thumb" & @CRLF & _
"|nationality = Russian" & @CRLF & _
"" & @CRLF & _
"{{Infobox officeholder" & @CRLF & _
"|image = Karenskiy AF 1917.jpg|thumb" & @CRLF & _
"|nationality = Russian" & @CRLF & _
"" & @CRLF & _
"{{Infobox officeholder" & @CRLF & _
"|image = Karenskiy AF 1917.jpg|230px|nationality = Russian" & @CRLF & _
"" & @CRLF & _
"|country=IND" & @CRLF & _
"|image= National Highway 2 (India).png|300px|Road map of India with NH 19 highlighted in solid blue color" & @CRLF & _
"|type=NH" & @CRLF & _
"" & @CRLF & _
"|image = File:April 14, 2012 Marquette, Kansas EF4 tornado.JPG|309px" & @CRLF & _
"" & @CRLF & _
"{{Infobox football club |" & @CRLF & _
" clubname = Slovácko |" & @CRLF & _
" image = Image:1FC Slovacko.png|150px|Logo |" & @CRLF & _
" fullname = 1. FC Slovácko A.S. |" & @CRLF & _
"" & @CRLF & _
"| image = <imagemap>" & @CRLF & _
"File:Primates - some families.jpg|300px"
Local $sSubst = "$1$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