2009-08-12 32 views

Respuesta

14

Cree un Matcher y use find() para posicionarlo en la próxima coincidencia.

15

Aquí es un ejemplo de código:

int countMatches(Pattern pattern, String str) { 
    int matches = 0; 
    Matcher matcher = pattern.matcher(str); 
    while (matcher.find()) 
    matches++; 
    return matches; 
} 
Cuestiones relacionadas