What's the correct regex for a String starting with $ char as the first argument (i.e. the string to replace) to Java's replaceAll method in the String class? I can't get the syntax right. Example
String s = "SUMIF($C$6:$C$475,\" India - Hyd\",K$6:K$475)";
System.out.println(s.replaceAll("$475", "$44"));
I would suggest in this case you use replace() instead of replaceAll(), because you're not using any regex:
System.out.println(s.replace("$475", "$44"));
This should work:
System.out.println(s.replaceAll("\\$475", "\\$44"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With