title: Why doesn't this RegEx match anything?
body: <p>I've been trying for about two hours now to write a regular expression which matches a single character that's not preceded or followed by the same character.</p>
  
  <p>This is what I've got: <code>(\d)(?&lt;!\1)\1(?!\1)</code>; but it doesn't seem to work! (testing at <a href="https://regex101.com/r/whnj5M/6" rel="nofollow noreferrer">https://regex101.com/r/whnj5M/6</a>)</p>
  
  <p>For example:</p>
  
  <p>In <code>1111223</code> I would expect to match the <code>3</code> at the end, since it's not preceded or followed by another 3.</p>
  
  <p>In <code>1151223</code> I would expect to match the <code>5</code> in the middle, and the <code>3</code> at the end for the same reasons as above.</p>
  
  <p>The end goal for this is to be able to find pairs (and only pairs) of characters in strings (e.g. to find <code>11</code> in <code>112223</code> or <code>44</code> in <code>123544</code>) and I was going to try and match single isolated characters, and then add a <code>{2}</code> to it to find pairs, but I can't even seem to get isolated characters to match! </p>
  
  <p>Any help would be much appreciated, I thought I knew RegEx pretty well!</p>
  
  <p>P.S. I'm testing in JS on regex101.com because it wouldn't let me use variable length lookbacks in Python on there, and I'm using the <a href="https://pypi.org/project/regex/" rel="nofollow noreferrer">regex</a> library to allow for this in my actual implementation.</p>