#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^ *(<[^\r\n<>]*>)|(\s*<[^\r\n<>]*>\s*)(?=[^\r\n<]*$)|<\/?color[^<>]*>"
Local $sString = "<color=#3D8CBF>using</color> <color=#00FFFF> aaa <Dont remove this tag> System</color>.Collections;" & @CRLF & _
"<color=#3D8CBF>using</color> <color=#00FFFF>System</color>.Collections.Generic;" & @CRLF & _
"<color=#3D8CBF>using</color> <color=#00FFFF>UnityEngine</color>;" & @CRLF & _
"" & @CRLF & _
"<color=#3D8CBF>public</color> <color=#3D8CBF>class</color> ChangePosition : <color=#00FF00>MonoBehaviour</color> {" & @CRLF & _
"" & @CRLF & _
" <color=#0000FF>// Update <color=#3D8CBF>is</color> called once per frame" & @CRLF & _
"</color>" & @CRLF & _
" <color=#3D8CBF>void</color> Update()" & @CRLF & _
" {" & @CRLF & _
" <color=#00FFFF>UnityEngine</color>.Profiling.Profiler.BeginSample("Test 1");" & @CRLF & _
" Test1();" & @CRLF & _
" <color=#00FFFF>UnityEngine</color>.Profiling.Profiler.EndSample();" & @CRLF & _
"" & @CRLF & _
" <color=#00FFFF>UnityEngine</color>.Profiling.Profiler.BeginSample("Test 2");" & @CRLF & _
" Test2();" & @CRLF & _
" <color=#00FFFF>UnityEngine</color>.Profiling.Profiler.EndSample();" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
""
Local $sSubst = "\1\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