Program: 35108
Project: 35108
Buggy source:
/** 
 * This function will try to add a number or operator, or entire result list to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single vaild number or operator character, or longer previous results
 */
public void keyPresses(String sKey){
  if (sKey.length() > 1) {
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (sKey.matches(regexHasInvalidChars))   throw new IllegalArgumentException("String_Node_Str");
  if (sKey.matches(regexInvalidStartChar) && (getLastPartialNumb().equals("String_Node_Str") || expresssionToSelection().matches("String_Node_Str")))   return;
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0)   addToExpressionStart("String_Node_Str");
  if (sKey.equals("String_Node_Str") && getLastPartialNumb().matches("String_Node_Str"))   if (!expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str"))   return;
  if (sKey.equals("String_Node_Str") && (getLastPartialNumb().contains("String_Node_Str") || expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")))   return;
  if (getLastPartialNumb().matches("String_Node_Str"))   if (sKey.matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyOperatorOrE) && getLastPartialNumb().equals("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + regexAnyValidOperator+ "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  mSolved=false;
}

Fixed version (ground truth):
/** 
 * This function will try to add a number or operator, or entire result list to the current expression Note that there is lots of error checking to be sure user can't entire an invalid operator/number
 * @param sKey should only be single valid number or operator character, or longer previous results
 */
public void keyPresses(String sKey){
  if (sKey.length() > 1) {
    if (mSolved)     replaceExpression(sKey);
 else     insertAtSelection(sKey);
    mSolved=false;
    return;
  }
  if (sKey.matches(regexHasInvalidChars))   throw new IllegalArgumentException("String_Node_Str");
  if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str"))   return;
  if (mSolved && sKey.matches("String_Node_Str"))   clearExpression();
  if (sKey.equals("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   sKey="String_Node_Str" + sKey;
  if (sKey.equals("String_Node_Str"))   if (numOpenPara() <= 0)   addToExpressionStart("String_Node_Str");
  if (sKey.equals("String_Node_Str") && getLastPartialNumb().matches("String_Node_Str"))   if (!expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str"))   return;
  if (sKey.equals("String_Node_Str") && (getLastPartialNumb().contains("String_Node_Str") || expresssionToSelection().matches("String_Node_Str" + regexAnyValidOperator + "String_Node_Str")))   return;
  if (getLastPartialNumb().matches("String_Node_Str"))   if (sKey.matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyOperatorOrE) && getLastPartialNumb().equals("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches("String_Node_Str") && expresssionToSelection().matches("String_Node_Str"))   return;
  if (sKey.matches(regexAnyValidOperator) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + regexAnyValidOperator+ "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
    backspaceAtSelection();
  }
 else   if (sKey.matches(regexInvalidStartChar) && expresssionToSelection().matches("String_Node_Str" + regexAnyOpExceptPercent + "String_Node_Str")) {
    if (getSelectionEnd() > getSelectionStart())     backspaceAtSelection();
    backspaceAtSelection();
  }
  insertAtSelection(sKey);
  mSolved=false;
}