title: Regex remove 2 sections of url at once
body: <p>I have these possible urls:</p>
  
  <pre><code>https://letterboxd.com/username/film/sometitle/
  https://letterboxd.com/username59/film/sometitle/1/
  https://letterboxd.com/username59/film/sometitle/2/
  </code></pre>
  
  <p>I want them all to display like this, without the username and without the trailing number if there is one:</p>
  
  <pre><code>https://letterboxd.com/film/sometitle/
  </code></pre>
  
  <p><strong>✔</strong> I can remove the trailing number, where it exists, with this:</p>
  
  <pre><code>=IF(REGEXMATCH(A2,"/film/(.*?)/\d/"), left(A2,len(A2)-2), A2)
  </code></pre>
  
  <p>result: <code>https://letterboxd.com/username59/film/sometitle/</code>
  I have to be careful here because if a film's title is just a digit, I don't want it to be replaced, so I specified that there had to be content between /film/ and the trailing digit. (eg, I have to distinguish between <code>film/9/</code> and <code>film/sometitle/9/</code></p>
  
  <p><strong>✔</strong>  I can remove the username with this (although I'll probably have to also account for other types of characters, come to think of it):</p>
  
  <pre><code>=REGEXREPLACE(A2, regexextract(A2, "\/[A-Za-z0-9]+\/"),"/")
  </code></pre>
  
  <p>result: <code>https://letterboxd.com/film/sometitle/2/</code></p>
  
  <p>❌ But I can't for the life of me figure out how to combine both to do it all in one formula! I can perform one of the formulas on the results of the other one, but I can't combine to have it all done in one fell swoop.  I've tried too many combinations to list here, but this one I thought was the most promising:</p>
  
  <pre><code>=REGEXREPLACE(A2, REGEXEXTRACT(IF(REGEXMATCH(A2,"/film/(.*?)/\d/"), left(A2,len(A2)-2), A2),"\/[A-Za-z0-9]+\/"),"/")
  </code></pre>
  
  <p>result: <code>https://letterboxd.com/film/sometitle/2/</code></p>
  
  <p>It didn't take care of the trailing <code>2/</code> and I don't know why. I'm guessing it's to do with some form of circularity? or the order of things?</p>