DEV Community

Discussion on: Daily Challenge #3 - Vowel Counter

Collapse
 
mdarrik profile image
Darrik Moberg

R with some Regex fun:

vowelCounter <- function(s) {
  vowelMatches <- sum(attr(gregexpr("[aeiou]",s, ignore.case = TRUE,
                                    perl= TRUE)[[1]],"match.length"),
                      na.rm = TRUE)
  vowelMatches[vowelMatches == -1 ] <- 0
  return(vowelMatches)
}