Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Assuming that your given regular expression is a <a href="http://msdn.microsoft.com/en-us/library/az24scfc.aspx" rel="nofollow">.NET regular expression</a>, the following syntax components are not supported by JavaScript:</p> <ul> <li><code>(?&gt;…)</code> – <a href="http://msdn.microsoft.com/en-us/library/bs2twtah.aspx#nonbacktracking_subexpression" rel="nofollow">nonbacktracking subexpression</a> </li> <li><code>(?&lt;name&gt;…)</code> – <a href="http://msdn.microsoft.com/en-us/library/bs2twtah.aspx#named_matched_subexpression" rel="nofollow">named matched subexpressions</a></li> <li><code>(?&lt;name1-name2&gt;…)</code> – <a href="http://msdn.microsoft.com/en-us/library/bs2twtah.aspx#balancing_group_definition" rel="nofollow">balancing group definition</a></li> <li><code>(?(name)…)</code> – <a href="http://msdn.microsoft.com/en-us/library/36xybswe.aspx#Conditional_Group" rel="nofollow">conditional group</a></li> </ul> <p>To get the same result with JavaScript, you’ll need to do the balancing on your own:</p> <pre><code>var parts = str.match(/[()]|[^()]+/g), matches = [], balance = 0; for (var i=0, j=0; i&lt;parts.length; i++) { switch (parts[i]) { case "(": if (balance === 0) { j = i; } balance++; break; case ")": if (balance === 1) { matches.push(parts.slice(j, i+1).join("")); } balance--; if (balance &lt; 0) { throw new EvalError('parentheses are not balanced; unexpected "("'); } break; } } if (balance &gt; 0) { throw new EvalError('parentheses are not balanced; missing ")"'); } </code></pre>
 

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