title: Regex for optional alphanumeric prefix and mandatory numeric suffix
body: <p>I am trying to build a regular expression which goal is to follow 3 rules:</p>
  
  <p><em>(1) If the input is alphanumeric and it could be split into two groups containing letters and numbers, then letters are prefix and numbers are suffix. For example:</em></p>
  
  <p><strong>input: ABC123</strong></p>
  
  <p><strong>output: prefix = ABC, suffix = 123</strong></p>
  
  <p><em>(2) If the input is numeric only, then there is no prefix, only suffix.
      For example:</em></p>
  
  <p><strong>input: 123</strong></p>
  
  <p><strong>output: prefix = '', suffix = 123</strong></p>
  
  <p><em>(3) If the input is mixed alphanumeric, then all numbers to each other at the end of input are suffix and all other characters are prefix</em></p>
  
  <p><strong>input: A9B9C123</strong></p>
  
  <p><strong>output: prefix = A9B9C, suffix = 123</strong></p>
  
  <hr>
  
  <p>I have tried this so far:</p>
  
  <pre><code>"(?P&lt;prefix&gt;\D*)(?P&lt;suffix&gt;\d*)"
  </code></pre>
  
  <p>This matches rules (1) and (2) but NOT (3).</p>
  
  <pre><code>"(?P&lt;prefix&gt;.*)(?P&lt;suffix&gt;[0-9]+)"
  </code></pre>
  
  <p>This matches rule (3), but breaks rules (1) and (2).</p>
  
  <p>Note: Input always ends with a number and prefix is optional.</p>
  
  <p>Thank you for your help.</p>