title: Replace Last Occurrence of a character in a string Using Java
body: <p>I am having a string like this</p>
  
  <pre><code>String s1 = "2999.1049.00_GRB.1";
  String s2 = "my File.txt.txt";
  </code></pre>
  
  <p>I want to replace the last ".1" with "_1" and ".txt" with "_txt"</p>
  
  <p>The result of the String should be </p>
  
  <pre><code>s1 = "2999.1049.00_GRB_1" and s2 = "my File.txt_txt"
  </code></pre>
  
  <p>How can I do this. I am aware of replacing the first occurrence of the string. but don't know how to replace the last occurrence of a string.</p>