title: Regex: group that must exist but it's unknown at advance where it will be
body: <p>I need to get <code>href</code> argument value, but only for those <code>&lt;link&gt;</code> tags which has <code>type='image/x-icon'</code> attribute (by other words, favicon tags):</p>
  
  <pre class="lang-html prettyprint-override"><code>// Below ones must be parsed
  &lt;link rel="icon" type="image/x-icon" href="#" /&gt;
  &lt;link rel="shortcut icon" type="image/x-icon" href="#" /&gt;
  
  // Below ones must be ignored
  &lt;link rel="stylesheet" href="styles.html"&gt;
  &lt;link rel="search" href="search.html"&gt;
  &lt;link rel="help" href="help.html"&gt;
  </code></pre>
  
  <p>The problem is <code>type="image/x-icon"</code> could be before <code>href="#"</code> or after it, but exactly one of these cases. How I can express it in regular expression from JavaScript?</p>
  
  <p> <a href="https://regex101.com/r/tujqBF/1" rel="nofollow noreferrer">Regex fiddle with my try</a></p>