#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)([A-Za-z_]\d*):(?!\d)|:([A-Za-z_])"
Local $sString = "2018-05-21T00:00:00+02:00" & @CRLF & _
"00:00:00" & @CRLF & _
"00:00" & @CRLF & _
":light at 07:15:0000" & @CRLF & _
"" & @CRLF & _
":occurence1" & @CRLF & _
":occurence2" & @CRLF & _
"" & @CRLF & _
"light: at 07:15:0000" & @CRLF & _
"" & @CRLF & _
"occurence1:" & @CRLF & _
"occurence2:" & @CRLF & _
"occurence10:" & @CRLF & _
"occurence20:"
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