title: javascript equivalent for python regex yes-pattern no-pattern
body: <p>In python there is a syntax for - if a capture group exists then x else y
  e.g.</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; pat = re.compile('(?:(a)|(c))b(?(1)a|c)') # should only match 'aba' or 'cbc'
  &gt;&gt;&gt; pat.match('abc')
  None
  &gt;&gt;&gt; pat.match('aba')
  &lt;re.Match object; span=(0, 3), match='aba'&gt;
  &gt;&gt;&gt; pat.match('cba')
  None
  &gt;&gt;&gt; pat.match('cbc')
  &lt;re.Match object; span=(0, 3), match='cbc'&gt;
  </code></pre>
  <p>How might one achieve a similar expression in javascript.</p>
  <p>Leading to a general approach for converting the python regex syntax to javascript</p>
  <pre class="lang-py prettyprint-override"><code>(?(id/name)yes-pattern|no-pattern)
  </code></pre>
  <p>I've tried a few ideas but haven't found an approach that's worked</p>