title: Regex backreference to match opposite case
body: <p>Before I begin &mdash; it may be worth stating, that: this <em>technically</em> does not have to be solved using a Regex, it's just that I immediately thought of a Regex when I started solving this problem, and I'm interested in knowing whether it's possible to solve using a Regex.</p>
  
  <hr>
  
  <p>I've spent the last couple hours trying to create a Regex that does the following.</p>
  
  <blockquote>
    <p>The regex must match a string that is ten characters long, <a href="https://en.wikipedia.org/wiki/If_and_only_if" rel="nofollow noreferrer">iff</a> the first five characters and last five characters are identical but each individual character is opposite in case.  </p>
    
    <p>In other words, if you take the first five characters, invert the case of each individual character, that should match the last five characters of the string.</p>
  </blockquote>
  
  <p>For example, the regex should match <code>abCDeABcdE</code>, since the first five characters and the last five characters are the same, but each matching character is opposite in case. In other words, <code>flip_case("abCDe") == "ABcdE"</code></p>
  
  <p>Here are a few more strings that <em>should</em> match: 
  <code>abcdeABCDE</code>, <code>abcdEABCDe</code>, <code>zYxWvZyXwV</code>.</p>
  
  <p>And here are a few that shouldn't match:  </p>
  
  <ul>
  <li><code>abcdeABCDZ</code>, although the case is opposite, the strings themselves do not match.</li>
  <li><code>abcdeABCDe</code>, is a very close match, but should not match since the <code>e</code>'s are not opposite in case.</li>
  </ul>
  
  <hr />
  
  <p>Here is the first regex I tried, which is obviously wrong since it doesn't account for the case-swap process.</p>
  
  <pre><code>/([a-zA-Z]{5})\1/g
  </code></pre>
  
  <p>My next though was whether the following is possible in a regex, but I've been reading several Regex tutorials and I can't seem to find it anywhere.</p>
  
  <pre><code>/([A-Z])[\1+32]/g
  </code></pre>
  
  <p>This new regex (that obviously doesn't work) is supposed to match a single uppercase letter, immediately followed by itself-plus-32-ascii, so, in other words, it should match an uppercase letter followed immediately by its' lowercase counterpart. But, as far as I'm concerned, you cannot "add an ascii value" to backreference in a regex.</p>
  
  <p><hr />
  And, bonus points to whoever can answer this &mdash; in this specific case, the string in question is known to be 10 characters long. Would it be possible to create a regex that matches strings of an arbitrary length?</p>