#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?:(?:(?:(\d+)d\s*)?((\d+)h\s*)?)?(\d+)m\s*)?((\d+)s)?$"
Local $sString = "1d 2h 3m 4s" & @CRLF & _
"1h 2m 3s" & @CRLF & _
"1m 2s" & @CRLF & _
"1s" & @CRLF & _
"1d2h3m4s" & @CRLF & _
"1h2m3s" & @CRLF & _
"1m2s" & @CRLF & _
"1s" & @CRLF & _
"15m" & @CRLF & _
"1d 3m"
Local $sSubst = ""
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