String is immutable , so questionText.replace(/[0-9]/g, ''); works on it, but does not change the questionText line. You will have to assign the result of replacing another String variable or the questionText itself.
var cleanedQuestionText = questionText.replace(/[0-9]/g, '');
or 1 time (using \d+ , see Kobe's answer):
questionText = ("1 ding ?").replace(/\d+/g,'');
and if you want to crop the leading (and final) space (s) while you are on it:
questionText = ("1 ding ?").replace(/\d+|^\s+|\s+$/g,'');
KooiInc Feb 14 '11 at 15:34 2011-02-14 15:34
source share