Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple matches within a regex group?
    primarykey
    data
    text
    <p>I need to match all 'tags' (e.g. %thisIsATag%) that occur within XML attributes. (Note: I'm guaranteed to receive valid XML, so there is no need to use full DOM traversal). My regex is working, except when there are <strong>two</strong> tags in a single attribute, only the last one is returned.</p> <p>In other words, this regex should find tag1, tag2, ..., tag6. However, it omits tag2 and tag5.</p> <p>Here's a fun little test harness for you (PHP):</p> <pre><code>&lt;?php $xml = &lt;&lt;&lt;XML &lt;data&gt; &lt;slideshow width="625" height="250"&gt; &lt;screen delay="%tag1%"&gt; &lt;text x="30%" y="50%" animatefromx="800"&gt; &lt;line fontsize="32" fontstyle="bold" text="Screen One!%tag2% %tag3%"/&gt; &lt;/text&gt; &lt;/screen&gt; &lt;screen delay='%tag4%'&gt; &lt;text x="30%" y="50%" animatefromx="800"&gt; &lt;line fontsize='32' fontstyle='bold' text='Screen 2!%tag5%%tag6%'/&gt; &lt;/text&gt; &lt;/screen&gt; &lt;screen&gt; &lt;text x="30%" y="50%" animatefromx="800"&gt; &lt;line fontsize="32" fontstyle="bold" text="Screen Tres!"/&gt; &lt;/text&gt; &lt;/screen&gt; &lt;screen&gt; &lt;text x="30%" y="50%" animatefromx="800"&gt; &lt;line fontsize="32" fontstyle="bold" text="Screen FOURRRR!"/&gt; &lt;/text&gt; &lt;/screen&gt; &lt;/slideshow&gt; &lt;/data&gt; XML; $matches = null; preg_match_all('#&lt;[^&gt;]+("([^%&gt;"]*%([^%&gt;"]+)%[^%&gt;"]*)+"|\'([^%&gt;\']*%([^%&gt;\']+)%[^%&gt;\']*)+\')[^&gt;]*&gt;#i', $xml, $matches); print_r($matches); ?&gt; </code></pre> <p>Thanks! :)</p>
    singulars
    1. This table or related slice is empty.
    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