I am trying to find the count of the substring in a big string of length 10000 characters. Finally I need to remove all the substring in it. example s = abacacac, subs
s = abacacac, subs
For countung the substrings I would use indexOf:
int count = 0; for (int pos = s.indexOf(substr); pos >= 0; pos = s.indexOf(substr, pos + 1)) count++;