How to remove numbers from a string?

前端 未结 7 1700
遇见更好的自我
遇见更好的自我 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:38

    You can use .match && join() methods. .match() returns an array and .join() makes a string

    function digitsBeGone(str){
      return str.match(/\D/g).join('')
    }
    

提交回复
热议问题