Note that there are some explanatory texts on larger screens.

plurals
  1. POregular expression for checking attributes in an html tag
    primarykey
    data
    text
    <p>In an HTML source I need to extract any simple text inside a FONT tag with exactly (no more, no less) these 3 attributes, in any order: size=5, color="red", face="verdana".</p> <p>The regular expression must thus for example extract all the following "randomtext" except the last four.</p> <pre><code>&lt;font size=5 color="red" face="verdana"&gt;randomtext&lt;/font&gt; &lt;font size=5 face="verdana" color="red"&gt;randomtext&lt;/font&gt; &lt;font color="red" size=5 face="verdana"&gt;randomtext&lt;/font&gt; &lt;font color="red" face="verdana" size=5&gt;randomtext&lt;/font&gt; &lt;font face="verdana" size=5 color="red"&gt;randomtext&lt;/font&gt; &lt;font face="verdana" color="red" size=5&gt;randomtext&lt;/font&gt; &lt;font size=5 size=5 size=5&gt;randomtext&lt;/font&gt; &lt;font face="verdana" color="red" size=5 foobar="random"&gt;randomtext&lt;/font&gt; &lt;font face="verdana" color="red" size=5 foobar="random=pippo"&gt;randomtext&lt;/font&gt; &lt;font face="verdana" color="red" size=5 garbagetext&gt;randomtext&lt;/font&gt; </code></pre> <p>I solved the "in any order" problem by using 3 look-aheads:</p> <pre><code>&lt;font(?=[^&gt;]* size=5)(?=[^&gt;]* color="red")(?=[^&gt;]* face="verdana")[^&gt;]*&gt;([^&lt;]+)&lt;/font&gt; </code></pre> <p>...or for more html flexibility:</p> <pre><code>&lt;\s*font(?=[^&gt;]*\s+size\s*=\s*5)(?=[^&gt;]*\scolor\s*=\s*["']red["'])(?=[^&gt;]*\sface\s*=\s*["']verdana["'])[^&gt;]*&gt;\s*([^&lt;]+?)\s*&lt;\s*/font\s*&gt; </code></pre> <p>The problem is that it also matches the last three. How can I exclude those matching? (obviously in a general and reasonable short/efficient way, i.e. without codyfing all possible positive combinations and without using literal negative expressions that work only on my examples)</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.
    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