Remove trailing numbers from string js regexp

后端 未结 2 1302
生来不讨喜
生来不讨喜 2020-12-02 01:43

I am trying to remove the trailing numbers from the string using JavaScript RegExp. Here is the example.

Input          output

-------------------------
st         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 02:36

    Use .replace():

    "string".replace(/\d+$/, '')
    

    A simple demo jsfiddle: http://jsfiddle.net/v8xvrze0/

提交回复
热议问题