How to remove numbers from a string?

前端 未结 7 1673
遇见更好的自我
遇见更好的自我 2020-12-12 19:56

I want to remove numbers from a string:

questionText = \"1 ding ?\"

I want to replace the number 1 number and the question mar

相关标签:
7条回答
  • 2020-12-12 20:56

    Just want to add since it might be of interest to someone, that you may think about the problem the other way as well. I am not sure if that is of interest here, but I find it relevant.

    What I mean by the other way is to say "strip anything that aren't what I am looking for, i.e. if you only want the 'ding' you could say:

    var strippedText = ("1 ding ?").replace(/[^a-zA-Z]/g, '');

    Which basically mean "remove anything which is nog a,b,c,d....Z (any letter).

    0 讨论(0)
提交回复
热议问题