#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?xm)[^[:graph:]*](?#Do not match on any visible character)" & @CRLF & _
"\K\*(?#Reset starting point and then match on a *)" & @CRLF & _
"([[:alpha:].,\ ]+(?:\*{2}[[:alpha:].,\ ]+\*{2}?\ ?)?)(*COMMIT)" & @CRLF & _
"\*\ ?(?#Match on ending * then stop matching with COMMIT)"
Local $sString = "This text is not italic." & @CRLF & _
"*This text is italic.*" & @CRLF & _
"This text is *partially* italic" & @CRLF & _
"This text has *two* *italic* bits" & @CRLF & _
"**bold text (not italic)**" & @CRLF & _
"**bold text with *italic* **" & @CRLF & _
"**part bold,** *part italic*" & @CRLF & _
"*italic text **with bold** *" & @CRLF & _
"*italic* **bold** *italic* **bold**" & @CRLF & _
"*invalid markdown (do not parse)**" & @CRLF & _
"random * asterisk"
Local $sSubst = "<i>$1</i> "
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