#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^([^-]*)->.*?(\[[^]]*\]);$"
Local $sString = "class1->Signal = sample1_sample2.sample3_sample4[4:4];" & @CRLF & _
"class2->Signal = sample1.sample2.sample3_sample4_sample5[2];" & @CRLF & _
"class3->Signal = sample1+sample2_sample3.sample4.sample5sample7[7:3];" & @CRLF & _
"class4->Signal = sample1[1]+sample2_sample3.sample4.sample5sample7[7:3];"
Local $sSubst = "$1 bit = $2"
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