title: How performing these two function?
body: <p>is possible perform these two function converting in a regular expression?</p>
  
  <pre><code>// Get all alpha-substring to left and before of any digits
  // otherwise return empty string.
  function ex1($source) {
    $string_alpha = "";
    $tmp = substr($source, 0, strcspn($source, '0123456789'));
    if (ctype_alpha($tmp)) { 
      $string_alpha = $tmp;
    }
    return $string_alpha;
  }
  
  // Get all numeric-substring to right and after last letter
  // otherwise return empty string.
  function ex2($source) {
    $string_numeric = "";
    $tmp = substr($source, strcspn($source, '0123456789'));
    if (ctype_digit($tmp)) { 
      $string_numeric = $tmp;
    }
    return $string_numeric;
  }
  
  $source = "butterfly12";
  echo "ex1 function =&gt; " . ex1($source) . "&lt;br&gt;";
  echo "ex2 function =&gt; " . ex2($source) . "&lt;br&gt;";
  
  // Output:
  // ex1 function =&gt; butterfly
  // ex2 function =&gt; 12   
  </code></pre>
  
  <p>I have tried to code about i need to do with these two example.
  Thanks very much.</p>