I do not understand why "$" is special.
String str = "bla aa";
String tag = "$";
str = str.replaceFirst("aa", tag);
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
If I change tag = "\\ $", then it works fine. But why do you have to run? thanks in advance.
source
share