<p>From the Java 6 <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html" rel="noreferrer">Pattern</a> documentation:</p>

<blockquote>
  <p>Special constructs (non-capturing)</p>
  
  <p><code>(?:</code><i>X</i><code>)</code>&nbsp;&nbsp;&nbsp;<i>X</i>, as a non-capturing group</p>
  
  <p>…</p>
  
  <p><code>(?></code><i>X</i><code>)</code>&nbsp;&nbsp;&nbsp;<i>X</i>, as an independent, non-capturing group</p>
</blockquote>

<p>Between <code>(?:X)</code> and <code>(?&gt;X)</code> what is the difference? What does the <strong>independent</strong> mean in this context?</p>

[{'answer_id': 50567, 'author': 'erickson', 'author_id': 3474, 'author_profile': 'https://Stackoverflow.com/users/3474', 'pm_score': 7, 'selected': True, 'text': '<p>It means that the grouping is <a href="http://www.regular-expressions.info/atomic.html" rel="noreferrer">atomic</a>, and it throws away backtracking information for a matched group. So, this expression is possessive; it won\'t back off even if doing so is the only way for the regex as a whole to succeed. It\'s "independent" in the sense that it doesn\'t cooperate, via backtracking, with other elements of the regex to ensure a match.</p>\n'}, {'answer_id': 394291, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': "<p>If you have <code>foo(?&gt;(co)*)co</code>, that will never match. I'm sure there are practical examples of when this would be useful, try O'Reilly's book.</p>\n"}, {'answer_id': 28663993, 'author': 'beibichunai', 'author_id': 4434482, 'author_profile': 'https://Stackoverflow.com/users/4434482', 'pm_score': -1, 'selected': False, 'text': '<p><code>(?&gt;X?)</code> equals <code>(?:X)?+</code>, <code>(?&gt;X*)</code> equals <code>(?:X)*+</code>, <code>(?&gt;X+)</code> equals <code>(?:X)++</code>.</p>\n<p>Taking away the fact that X must be a non-capturing group, the preceding equivalence is:</p>\n<p><code>(?&gt;X?)</code> equals <code>X?+</code>, <code>(?&gt;X*)</code> equals <code>X*+</code>, <code>(?&gt;X+)</code> equals <code>X++</code>.</p>\n'}, {'answer_id': 50146523, 'author': 'kajibu', 'author_id': 7320818, 'author_profile': 'https://Stackoverflow.com/users/7320818', 'pm_score': 4, 'selected': False, 'text': '<p>I think <a href="https://www.regular-expressions.info/atomic.html" rel="noreferrer">this tutorial</a> explains what exactly "independent, non-capturing group" or "Atomic Grouping" is </p>\n\n<p>The regular expression <code>a(bc|b)c</code> (capturing group) matches <strong>abcc</strong> and <strong>abc</strong>. The regex <code>a(?&gt;bc|b)c</code> (atomic group) matches <strong>abcc</strong> but not <strong>abc</strong>.</p>\n\n<p>When applied to <strong>abc</strong>, both regexes will match <code>a</code> to <strong>a</strong>, <code>bc</code> to <strong>bc</strong>, and then <code>c</code> will fail to match at the end of the string. Here their paths diverge. The regex with the <strong><em>capturing group</em></strong> has remembered a backtracking position for the alternation. The group will give up its match, <code>b</code> then matches <strong>b</strong> and <code>c</code> matches <strong>c</strong>. Match found!</p>\n\n<p>The regex with the <strong><em>atomic group</em></strong>, however, exited from an atomic group after <code>bc</code> was matched. At that point, all backtracking positions for tokens inside the group are discarded. In this example, the alternation\'s option to try <code>b</code> at the second position in the string is discarded. As a result, when <code>c</code> fails, the regex engine has no alternatives left to try.</p>\n'}]
['https://Stackoverflow.com/questions/50524', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4265/']