String first = "/Some object that has a loop in it object/";
String second = "object";
Pattern pattern = Pattern.compile(second);
Matcher matcher = pattern.matcher(first) ;
long count = 0;
while(matcher.find()) {
count ++;
}
System.out.println(count);