#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?m)(.*\n)*(.+?)(5)\[(.*)\](.\n)*(.*\n*)*"
Local $sString = "SHIELD1[1SHIELD,2SHIELDCAP,3SHIELDPERCENT,]" & @CRLF & _
"ENERGY2[1POWER,2POWERCAP,3POWERPERCENT,]" & @CRLF & _
"STRUCTURE3[1STRUCTUREHP,2STRUCTUREHPCAP,3STRUCTUREHPPERCENT,]" & @CRLF & _
"ARMOR4[1ARMORHP,2ARMORHPCAP,3ARMORHPPERCENT,]" & @CRLF & _
"OTHER5[1MASS,2BLOCKCOUNT,3SECTOR,4SYSTEM,]" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"SELECT THE MENU YOU WANT" & @CRLF & _
"" & @CRLF & _
"[REPLACEFIRST](.*\n)*(.+?)(3)\[(.*)\](.\n)*(.*\n*)*[WITH]$4"
Local $sSubst = "$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