title: Java Get first character values for a string
body: <p>I have inputs like </p>
  
  <blockquote>
    <p>AS23456SDE</p>
    
    <p>MFD324FR</p>
  </blockquote>
  
  <p>I need to get First Character values like </p>
  
  <blockquote>
    <p>AS, MFD</p>
  </blockquote>
  
  <p>There should <em>no first two or first 3 characters input can be changed</em>. Need to get <strong>first characters before a number</strong>.</p>
  
  <p>Thank you.</p>
  
  <p>Edit : This is what I have tried.</p>
  
  <pre><code>public static String getPrefix(String serial) {
      StringBuilder prefix = new StringBuilder();
          for(char c : serial.toCharArray()){
              if(Character.isDigit(c)){
                  break;
              }
              else{
                  prefix.append(c);
              }
          }
          return prefix.toString();
  }
  </code></pre>