1import java.util.regex.*;
2
3class Test {
4 public static void main(String[] args) {
5 String hello = "HelloxxxHelloxxxHello";
6 Pattern pattern = Pattern.compile("Hello");
7 Matcher matcher = pattern.matcher(hello);
8
9 int count = 0;
10 while (matcher.find())
11 count++;
12
13 System.out.println(count); // prints 3
14 }
15}