title: Regex match repeating patterns but not last occurrence
body: <p>I would like to extract the following patterns:</p>
  <ol>
  <li><p>Initial by letter (Subgroup 1); and then</p>
  </li>
  <li><p>followed by numbers of any length (Subgroup 2);</p>
  </li>
  <li><p>followed by letter or any length (Subgroup 3);</p>
  </li>
  <li><p>repeating 2 &amp; 3 of any occurrences.</p>
  </li>
  </ol>
  <p>I am using <a href="https://regexr.com/" rel="nofollow noreferrer">https://regexr.com/</a> to test.</p>
  <p>Here are some samples string and my expected output.</p>
  <pre><code>String: FAF46ABC7787AAAA  =&gt;   Desired output: FAF46ABC7787
  
  String: FAF46ABC7787      =&gt;   Desired output: FAF46ABC
  
  String: FAF46ABC          =&gt;   Desired output: FAF46
  
  String: FAF46             =&gt;   Desired output: FAF
  
  String: FAF               =&gt;   Desired output: FAF
  
  String: FAF46 GG(Not CC)  =&gt;   Desired output: FAF
  
  String: FAF46.doc         =&gt;   Desired output: FAF
  </code></pre>
  <p>I tested the following but not working:</p>
  <ol>
  <li>Lookahead method suggested by</li>
  </ol>
  <p><a href="https://stackoverflow.com/questions/16203365/python-regex-matching-all-but-last-occurrence">Python regex matching all but last occurrence</a></p>
  <p>1a. <code>^([a-zA-Z]+)([0-9]*[a-zA-Z]*)(?=[0-9]+|[a-zA-Z]+)</code></p>
  <p>1b. <code>^([a-zA-Z]+)(([0-9])*([a-zA-Z])*)(?=[0-9]+|[a-zA-Z]+)</code></p>
  <ol start="2">
  <li>Capture all subgroups and exclude last occurrence by loop</li>
  </ol>
  <p>2a. <code>^([a-zA-Z]+)(([0-9]*)([a-zA-Z]*))*</code></p>
  <ol start="3">
  <li>Using replace method</li>
  </ol>
  <p>3a. <code>(^(?:[a-zA-Z]+[0-9]*)(?:[a-zA-Z]+[0-9]*)*)([a-zA-Z]+|[0-9]+)</code> and replace by $1</p>
  <ol start="4">
  <li>Exclude ending occurrence by using non-capturing group</li>
  </ol>
  <p>4a. <code>^([a-zA-Z]+)(([0-9]*)([a-zA-Z]*))*(?:[0-9]+|[a-zA-Z]+)$</code></p>
  <p>4b. <code>^([a-zA-Z]+)(([0-9]*)([a-zA-Z]*))*(?:([0-9]+|[a-zA-Z]+))$</code></p>
  <p>4c. <code>^([a-zA-Z]+)(([0-9]*)([a-zA-Z]*))*(?:[0-9a-zA-Z]+)$</code></p>
  <p>4d. <code>^([a-zA-Z]+)(([0-9]*?)([a-zA-Z]*?))*(?:[0-9a-zA-Z]+)$</code></p>
  <p>I also change greedy or lazy to see if any miracles happen. But no luck.</p>
  <p>I thought it should be easy task. But it is obvious that it is harder than what I thought.</p>
  <p>I would appreciate for any kind of help.</p>
  <p>Please note that I do not have extended regex if it is the case to work it work.
  Thank you.</p>