title: Using Regex to find words with characters that are the same or that are different
body: <p>I have a list of words such as:</p>
  
  <pre><code>l = """abca
  bcab
  aaba
  cccc
  cbac
  babb
  """
  </code></pre>
  
  <p>I want to find the words that have the same first and last character, and that the two middle characters are different from the first/last character.</p>
  
  <p>The desired final result:</p>
  
  <pre><code>['abca', 'bcab', 'cbac']
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>re.findall('^(.)..\\1$', l, re.MULTILINE)
  </code></pre>
  
  <p>But it returns all of the unwanted words as well.
  I thought of using [^...] somehow, but I couldn't figure it out.
  There's a way of doing this with sets (to filter the results from the search above), but I'm looking for a regex.</p>
  
  <p>Is it possible?</p>