Remove word after last dash with regex in JavaScript
javascript, regex
Solution
You can use `-[^-]*$` to replace "dash followed by zero or more non-dash characters anchored to the end of the string." You may also just want to use `(-test)*$` to replace all `-test` instances at the end of the string.
Problem
I’ve defined string `word-word-word-test` and I want to remove the `-test` (all behind the last dash). How can I do that with a RegEx? My `/-.*$/` works only if there are no other dashes in the string.