I have a string that ends with a fixed word - Button
. Now I need to replace that word with ''
. How can I do it? Also, if my string is something like ButtonButton
or similar, I need to cut out only last Button
.
var original = 'ButtonButton';
var newString = original.replace(/Button$/, '');
// "Button"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With