title: Replace last occurrence word in javascript
body: <p>I have a problem with replacing last word in JS, I am still searching solution but i cannot get it.</p>
  
  <p>I have this code:  </p>
  
  <pre><code>var string = $(element).html(); // "abc def abc xyz"
  var word   = "abc";
  var newWord = "test";
  
  var newV   = string.replace(new RegExp(word,'m'), newWord);
  </code></pre>
  
  <p>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?</p>