I have a problem with replacing last word in JS, I am still searching solution but i cannot get it.
I have this code:
var string = $(element).html(); // abc def abc xyz
var word = abc;
var newWord = test;
var newV = string.replace(new RegExp(word,'m'), newWord);
I want replace last word abc in this string, but now I can only replace all or first occurrence in string. How can I do this? Maybe is not good way?