#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?!\s)(.{3,10}\S)(?!\S).*"
Local $sString = "This is a long string" & @CRLF & _
"this is a test cutting down edges" & @CRLF & _
"a b c d e f g h" & @CRLF & _
"abcd" & @CRLF & _
"abcde" & @CRLF & _
"this isatest" & @CRLF & _
"is a test" & @CRLF & _
"ist a test" & @CRLF & _
"ist a te " & @CRLF & _
"thiss is a test" & @CRLF & _
"a b" & @CRLF & _
"a " & @CRLF & _
"S" & @CRLF & _
"a" & @CRLF & _
"ab" & @CRLF & _
"abc" & @CRLF & _
"abcd" & @CRLF & _
"abcde" & @CRLF & _
"A bcdefghifkkle" & @CRLF & _
"abcd ef g aaa" & @CRLF & _
"abcd ef g aa" & @CRLF & _
"thisisatesttesttest" & @CRLF & _
"abcdefghijkl" & @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