fork(2) download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3. var s = '你好吗17这里是cnode34.5你知道nodejs67.23吗';
  4. var reg = /[+-]?\d+\.?\d*/g;
  5. var sum = 0.0;
  6. var expr;
  7. numbers = s.match(reg);
  8. if (numbers != null){
  9. for (v in numbers) {
  10. if (v == 0)
  11. expr = numbers[v];
  12. else
  13. expr += '+' + numbers[v];
  14. sum += parseFloat(numbers[v]);
  15. }
  16. }
  17. console.log(expr + '=' + sum);
Success #stdin #stdout 0.06s 10968KB
stdin
Standard input is empty
stdout
17+34.5+67.23=118.73