rem: var rgx = new RegExp("[^a-z]?("+v.name+")[^a-z]?","gi");  var m = rgx.exec(formula); 
add:  var rgx = new RegExp("[^a-z]+("+v.name+")[^a-z]+","gi");  var m = rgx.exec(' '+formula+' '); 
context: wFORMS.behaviors.calculation.instance.prototype.compute = function(calculation) {	var f = this.target;	var formula = calculation.formula;		for(var i=0; i<calculation.variables.length;i++) {		var v = calculation.variables[i];		var varval = 0;		var _self  = this;		// we don't rely on calculation.variables[i].field because 		// the form may have changed since we've applied the behavior		// (repeat behavior for instance).		// TODO: Exclude switched-off variables?		f.matchAll("*[class*=\""+wFORMS.behaviors.calculation.VARIABLE_SELECTOR_PREFIX+v.name+"\"]").forEach(			function(f){				// If field value has a different purpose, the value for the calculation can be set in the				// class attribute, prefixed with CHOICE_VALUE_SELECTOR_PREFIX 				var value = _self.getValueFromClassName(f);								if(!value)					value = wFORMS.helpers.getFieldValue(f);				if(!value) value=0;									if(value.constructor.toString().indexOf("Array") !== -1) { // array (multiple select)					for(var j=0;j<value.length;j++) { 						varval += parseFloat(value[j]);					}				} else {					varval += parseFloat(value);				}			}		);			    var rgx = new RegExp("[^a-z]?("+v.name+")[^a-z]?","gi");	   	    var m = rgx.exec(formula);	    if (m) {	    	if(m[1])				formula = formula.replace(m[1], varval);			else				formula = formula.replace(m[0], varval);	    }			} 	try {		var result = eval(formula);//		if(result=='Infinity' || result=='NaN') {		// [don] Added for Safari		// TODO check if "result == 'NaN'" result == 'Infinity' is neccessary		if(result == 'Infinity' || result == 'NaN' || isNaN(result)){			result = 'error';		}	} catch(x) {				result = 'error';			} 	// Check if validation behavior is available. Then flag field if error.	var validationBehavior = wFORMS.getBehaviorInstance(this.target,'validation');		if(validationBehavior) {				// add validation error message 		if(!wFORMS.behaviors.validation.messages['calculation']) {			wFORMS.behaviors.validation.messages['calculation'] = this.behavior.CALCULATION_ERROR_MESSAGE;		}		validationBehavior.removeErrorMessage(calculation.field);		if(result=='error') {						validationBehavior.fail(calculation.field, 'calculation');		}	}	calculation.field.value = result;		// If the calcualted field is aslo a variable, recursively update dependant calculations	if(calculation.field.className && (calculation.field.className.indexOf(this.behavior.VARIABLE_SELECTOR_PREFIX)!=-1)) {		// TODO: Check for infinite loops?		this.run(null,calculation.field);	} }
meta: 8955	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/8955/b4c3f459a214f1abf932ebf4eecf8504548aeec6/wforms_calculation.js/clean/branches/3.0/wforms_calculation.js