#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "^[^\d+-]*([+-]?)\s*+(\d++(?:\.\d+)?)|\G[^\d+-]*(?:([+-])\s*+((?2))|((?2)))|[+-]++|[^+-]++"
Local $sString = " Lorem ipsum dolor sit amet." & @CRLF & _
" Nullam 000 ut finibus 111 lectus." & @CRLF & _
" Praesent 222 eu 333 sem lorem." & @CRLF & _
" Fusce elementum 444 gravida 555 luctus." & @CRLF & _
" Sed non "accumsan" - 777 lorem!" & @CRLF & _
" 1. Vivamus at mauris mi.[1]" & @CRLF & _
" 2. Duis ac faucibus elit.[2][3]" & @CRLF & _
" 3. Sed sed 'tempor' diam.[4,5]" & @CRLF & _
" Vivamus 2024-12-21 tincidunt tristique dolor." & @CRLF & _
" "Morbi vel blandit augue?"" & @CRLF & _
" Morbi eu tortor 25.25 ligula."
Local $sSubst = "${2:+$1$2}${3:+$3$4}${5:++$5}"
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