#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?:<span[^>]*?>)(?!<a)(.*?)(?:<\/span>)"
Local $sString = "<span style="font-family: inherit; font-weight: inherit; line-height: 1.3;"> <b>including their</b> </span>" & @CRLF & _
"" & @CRLF & _
"<span style="font-family: inherit; font-weight: inherit; line-height: 1.3;">StackOverflow</span>" & @CRLF & _
"" & @CRLF & _
"<span class="MainLink" style="font-weight: bold"><a href="https://website.com/" style="color: #2f82de; text-decoration: none">link name</a></span>" & @CRLF & _
"" & @CRLF & _
"<a href="http://www.google.com"><span>testing</span></a>"
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