#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)[Xx]yz(?=[^<>]*<)(?!(<(?:a|span)>(?:.|\n))*</(?:span|a)>)"
Local $sString = "xyz" & @CRLF & _
"Company name nissan and Xyz abc product." & @CRLF & _
"<p>Company name xyz and xyz abc product.</p>" & @CRLF & _
"" & @CRLF & _
"<a href="xyz"><span>Xyz</span></a>" & @CRLF & _
"<a href="Xyz"><span>xyz</span></a>" & @CRLF & _
"<span>xyz</span>" & @CRLF & _
"<p>You know Nissan become now <a href="xyz.com"><span>xyz</span></a> Micra.</p>" & @CRLF & _
"" & @CRLF & _
"You know xyz become now http://www.xyz.com. " & @CRLF & _
"<p>Now .xyz. become now www.xyz.com</p>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<p>www.xyz.com</p>" & @CRLF & _
"<p>Hello you know Xyz is Now xyz become now www.xyz.com</p>" & @CRLF & _
"" & @CRLF & _
""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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