js/calc.js
/**
 * This function attempts to repair the misstyped and redundant operators,
 * by returning only the first valid operator.
 * e.g.: -+5+*!+/3+, result: -5+3.
 * Secondly, it attempts to repair redundant operators in parenthesis,
 * e.g.: (*5+6/), result: (5+6).
 * @param exp String of expression to attempt to repair.
 * @return String repaired expression.
 * */
This function attempts to repair the misstyped and redundant operators,
by returning only the first valid operator.
This function attempts to repair the misstyped and redundant operators by returning only the first valid operator .
function repairOperators(exp)
{
	var rx = /([\^\*\+\/\-]{2,})/g;
	exp = exp.replace(rx, useFirstOp);
	rx = /(\()([\^\*\+\/\-!]+)([A-Za-z0-9~])/g;
	exp = exp.replace(rx, "$1$3");
	rx = /([A-Za-z0-9~])([\^\+\/\-!]+)(\))/g;
	exp = exp.replace(rx, "$1$3");
	return exp;
}
function repairOperators ( exp ) { var rx = / ([\^\*\+\/\-]{2,}) / g ; exp = exp . replace ( rx , useFirstOp ) ; rx = / (\()([\^\*\+\/\-!]+)([A-Za-z0-9~]) / g ; exp = exp . replace ( rx , "$1$3" ) ; rx = / ([A-Za-z0-9~])([\^\+\/\-!]+)(\)) / g ; exp = exp . replace ( rx , "$1$3" ) ; return exp ; }
This function attempts to repair the misstyped and redundant operators,
 by returning only the first valid operator.
This function attempts to repair the misstyped and redundant operators by returning only the first valid operator .
//maybeTODO: temporarily removed * and !