Well then I think you're going about it wrong. Here is a better way to do it. The code, however, is a bit messy. This will evaluate division, multiplication, addition, and subtraction (/, *, +, -). It uses the
eval() function. It accepts decimals and disregards whitespace. However, there is only support for problems with two numbers (3*4*5 won't work).
code:
var Str = "Did you know that 5 time 5 is 5*5? Did you know that 8 plus 8 is 8+8?";
var RegExp = /[\d.]+[\s]*[*/+-][\s]*[\d.]+/g;
Str = Str.replace(RegExp, function(){ var res = eval(RegExp.exec(Str)[0]); RegExp.lastIndex++; return res; } );