private static int countWildcardsOccurrences ( String templateMessage , String occurrence ) { if ( templateMessage != null && occurrence != null ) { final Pattern pattern = Pattern . compile ( occurrence ) ; final Matcher matcher = pattern . matcher ( templateMessage ) ; int count = 0 ; while ( matcher . find ( ) ) { count ++ ; } return count ; } else { return 0 ; } }
Count the number of occurrences of a given wildcard .