#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)(?s:" & @CRLF & _
"<ins" & @CRLF & _
"(?:(?!</ins>).)*?" & @CRLF & _
""adsbygoogle"" & @CRLF & _
".*?" & @CRLF & _
"</ins>)"
Local $sString = " 0" & @CRLF & _
"down vote" & @CRLF & _
"favorite" & @CRLF & _
" " & @CRLF & _
"" & @CRLF & _
"I have a thousand html pages (without admin panel) with codes of adsense. And I want to remove all of them from html. One code looks like:" & @CRLF & _
"" & @CRLF & _
"<ins class="adsbygoogle"" & @CRLF & _
" style="display:inline-block;width:160px;height:600px"" & @CRLF & _
" data-ad-client="ca-pub-7165746718333100"" & @CRLF & _
" data-ad-slot="9087512399"></ins>" & @CRLF & _
"" & @CRLF & _
"Another:" & @CRLF & _
"" & @CRLF & _
"<ins class="adsbygoogle"" & @CRLF & _
" style="display:inline-block;width:160px;height:600px"" & @CRLF & _
" data-ad-client="ca-pub-7163746711373100"" & @CRLF & _
" data-ad-slot="7467236139"></ins>" & @CRLF & _
"" & @CRLF & _
"All of them are similar but not equal. A tried to write regex to find and replace it with empty string, but unsuccessfully." & @CRLF & _
"" & @CRLF & _
"Any suggetion how to do it automatically?" & @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