#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m).*?($|\$[sc]\d)"
Local $sString = " Есть текст и много строк" & @CRLF & _
"В тексте встречаются $s1 $s2 $s3 $s4 $c1 $c2 $c4" & @CRLF & _
"В каждой строке есть хоть 1 такой текст, могут быть и 2 и 3 в 1 строке, но без дублей." & @CRLF & _
"" & @CRLF & _
"Найти я смог их так (\$s\d)|(\$c\d) и удалить могу их всех, но как удалить все кроме них не понял." & @CRLF & _
"Заранее спасибо за ответ! "
Local $sSubst = "$1"
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