I\'m trying to replace the last dot in a String using a regular expression.
Let\'s say I have the following String:
String string = \"hello.world.how
One way would be:
string = string.replaceAll("^(.*)\\.(.*)$","$1!$2");
Alternatively you can use negative lookahead as:
string = string.replaceAll("\\.(?!.*\\.)","!");
Regex in Action