Vuoi trovare tutti i match all'interno di txtContent?
Prova così:
codice:
String txtContent="IT123456789s sds it11111111111,jkjiT11111131611";
Pattern pattern = Pattern.compile("IT\\d{9}", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(txtContent);
int numeroRiscontri=0;
int i=0;
while(matcher.find(i)){
int start=matcher.start();
int end=matcher.end();
String temp=txtContent.substring(start, end);
System.out.println(temp);
numeroRiscontri++;
i=end;
}
System.out.println(numeroOccorrenze);