height_val = $("#id_height").val(); var regex_op = /^(\d{1,2})[\']?((\d)|([0-1][0-2]))?[\"]?$/g.exec(height_val); //very rare chance for someone to be of two digit feet height. //but i put it there, just in case. var feet = regex_op[1]; var inches = regex_op[2]; // converting to inches var height = (parseInt(feet) || 0) * 12 + (parseInt(inches) || 0);