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+$/, "")
More Related Contents:
- javascript regex
- How to use JavaScript regex over multiple lines?
- Including a hyphen in a regex character bracket?
- javascript regex – look behind alternative?
- Get Substring between two characters using javascript
- Named capturing groups in JavaScript regex?
- Javascript Regexp dynamic generation from variables? [duplicate]
- Positive look behind in JavaScript regular expression
- Fastest way to check a string contain another substring in JavaScript?
- Check if a string is html or not
- How to test valid UUID/GUID?
- Capture value out of query string with regex?
- Get URL from background-image Property
- Regular expression for all printable characters in JavaScript
- Regex currency validation
- Wrap tags around http text
- regex javascript to match both RGB and RGBA
- jQuery Youtube URL Validation with regex
- Why can’t I use accented characters next to a word boundary?
- Trim spaces from start and end of string
- How to convert a Title to a URL slug in jQuery?
- Optimize long lists of fixed string alternatives in regex
- Replace certain arabic words in text string using Javascript
- What does the “Nothing to repeat” error mean when using a regex in javascript?
- Regular expression for number with length of 4, 5 or 6
- Regex for allowing alphanumeric,-,_ and space
- Get filename from string path in javascript?
- How to use a regular expression in querySelectorAll?
- What’s the use of the [\b] backspace regex?
- How to replace non-printable unicode characters (Javascript)