#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(\n\n)-\s*(?!.*(?:(?<!-)\n-|\n-))"
Local $sString = "Here are few example strings where a leading dash character should be removed (note newlines):" & @CRLF & _
"" & @CRLF & _
"- Lovely day." & @CRLF & _
"" & @CRLF & _
"- Lovely day-night cycle." & @CRLF & _
"" & @CRLF & _
"- Lovely day." & @CRLF & _
"Isn't it?" & @CRLF & _
"" & @CRLF & _
"- lovely day - isn't it?" & @CRLF & _
"" & @CRLF & _
"- Lovely day -" & @CRLF & _
"isn't it?" & @CRLF & _
"" & @CRLF & _
"Here are few example strings where leading dash character(s) should be retained (note the 2nd example, it might be tricky):" & @CRLF & _
"" & @CRLF & _
"- Lovely day." & @CRLF & _
"- Yeah, isn't it?" & @CRLF & _
"" & @CRLF & _
"Lovely day." & @CRLF & _
"- Yeah, isn't it?" & @CRLF & _
"" & @CRLF & _
"- lovely day - isn't it?" & @CRLF & _
"- Yes." & @CRLF & _
"" & @CRLF & _
"- Lovely day for a -" & @CRLF & _
"- Walk?" & @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