I have to String objects:
String first = \"/Some object that has a loop in it object/\";
String second = \"object\";
What I need to do is find
Use regex, example:
import java.util.regex.*;
class Test {
public static void main(String[] args) {
String hello = "HelloxxxHelloxxxHello"; //String you want to 'examine'
Pattern pattern = Pattern.compile("Hello"); //Pattern string you want to be matched
Matcher matcher = pattern.matcher(hello);
int count = 0;
while (matcher.find())
count++; //count any matched pattern
System.out.println(count); // prints how many pattern matched
}
}
source: java regex match count