Remove trailing numbers from string js regexp

You could use this regex to match all the trailing numbers.

\d+$

Then remove the matched digits with an empty string. \d+ matches one or more digits. $ asserts that we are at the end of a line.

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

Leave a Comment