The following regex matches the first instance of 'STACK' found in any string that begins with HTML comment tags
(?:\<\!\-\-).*?(\bSTACK\b).*?(?=\>)
So, for example, at the moment only the first 'STACK' in the string below is matched, and I want both to be matched.
<!-- test test STACK test test STACK -->
First question: what do I need to change so this will match all instances (with and without the word boundary)?
Further Difficulty
The title of this question refers to replacing all instances in specific sections of a HTML document / ASP.Net page
An example of a document that I wish to use Regex.Replace (c#) with might look like:
<asp:Content>
<div>some text STACK some text STACK123</div>
</asp:Content>
<asp:Content>
<!-- SOLR {"description":"some text<br/> <b>bold stuff</b>", "summary":"some text <b>STACK123/<b> some text STACK"} SOLR --->
</asp:Content>
I already have another regex which works for the ASP.net / HTML elements (in c#, not in php/javascript etc):
(?<!<[^>]*?)bSTACK
This matches all instances of 'STACK' that are inside HTML elements / ASP.Net tags.
I was unable to find a way to extend this / combine this with the first regex above to work inside comment tags too, so I'm currently planning to use two separate Regex.Replaces to achieve what I want, unless...
Second question: does one of you geniuses know a way of achieving what I want in a single line of regex...?
Further Examples - Example & Expected Results
<asp:Content>
<div>some text STACK some text STACK123</div>
</asp:Content>
<asp:Content>
<!-- SOLR {"description":"some text", "summary":"some text STACK123 some text STACK"} SOLR --->
</asp:Content>
Should match:
<asp:Content>
<div>some text
STACKsome text
STACK123</div>
</asp:Content>
<asp:Content>
<!-- SOLR {"description":"some text", "summary":"some text
STACK123 some text
STACK"} SOLR --->
</asp:Content>