Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming a well-formed html document with outer/enclosing tags like <code>&lt;html&gt;</code>, I would think the easiest way would be to look for the <code>&gt;</code> and <code>&lt;</code> signs:</p> <pre><code>/(\&gt;[^\&gt;\&lt;]*)ZZZ([^\&gt;\&lt;]*\&lt;)/$1AAA$2/ </code></pre> <p>If you're dealing with HTML fragments that may not have enclosing tags, it gets a little more complicated, you'd have to allow for start of string and end of string</p> <p>Example JS (sorry, missed the tag):</p> <pre><code>alert('&lt;A HREF="ZZZ"&gt;test test ZZZ&lt;SPAN&gt;ZZZ test test&lt;/SPAN&gt;&lt;/A&gt;'.replace(/(\&gt;[^\&gt;\&lt;]*)ZZZ([^\&gt;\&lt;]*\&lt;)/g, "$1AAA$2")); </code></pre> <p><strong>Explanation</strong>: for each match that </p> <ul> <li>starts with <code>&gt;</code>: <code>\&gt;</code></li> <li>follows with any number of characters that are neither <code>&gt;</code> nor <code>&lt;</code>: <code>[^\&gt;\&lt;]*</code></li> <li>then has "ZZZ"</li> <li>follows with any number of characters that are neither <code>&gt;</code> nor <code>&lt;</code>: <code>[^\&gt;\&lt;]*</code></li> <li>and ends with <code>&lt;</code>: <code>\&lt;</code></li> </ul> <p>Replace with </p> <ul> <li>everything before the ZZZ, marked with the first capture group (parentheses): <code>$1</code></li> <li>AAA</li> <li>everything after the ZZZ, marked with the second capture group (parentheses): <code>$2</code></li> </ul> <p>Using the "g" (global) option to ensure that all possible matches are replaced.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload