Last active
June 1, 2017 19:06
-
-
Save MaxXxiMast/7299eedaf13f4c229ccf9606d8331742 to your computer and use it in GitHub Desktop.
Check the number of vowels in a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countVowels(str){ | |
return (str.match(/[aeiou]/gi) == null) ? 0 : str.match(/[aeiou]/gi).length; | |
} | |
// return (str.match(/[aeiou]/gi) || []).length; - shorter version | |
// [aeiou] can be replaced by any other regex as per requirement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment