title: Replace the last occurence of a string (and only it) using regular expression
body: <p>I have a string, let say MyString = "aabbccawww". I would like to use a gsub expression to replace the last "a" in MyString by "A", <strong>and only it</strong>. That is "aabbccAwww". I have found similar questions on the website, but they all requested to replace the last occurrence and everything coming after.
  I have tried gsub("a[^a]*$", "A", MyString), but it gives "aabbccA". I know that I can use stringi functions for that purpose but I need the solution to be implemented in a part of a code where using such functions would be complicated, so I would like to use a regular expression.
  Any suggestion?</p>