Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALNUM = /[a-z0-9]/i
- PUNCT = /[^a-z0-9\s]/i
- REPEAT = /(.)\1{2,}/
- UPPER = /[A-Z]/
- LOWER = /[a-z]/
- ACRONYM = /^[A-Z]+('?s|[.,])?$/
- ALL_ALPHA = /^[a-z]+$/i
- CONSONANT = /[bcdfghjklmnpqrstvwxz]/i
- VOWEL = /[aeiouy]/i
- CONSONANT_5 = /[bcdfghjklmnpqrstvwxz]{5}/i
- VOWEL_4 = /[aeiouy]{4}/i
- # More than 20 bytes in length.
- w.length > 20
- # More punctuation than alpha numerics.
- w.length > 2 && (w.scan(ALNUM).length < w.scan(PUNCT).length)
- # Ignoring the first and last characters in the string, if there are three or
- # more different punctuation characters in the string.
- w[1...-1].scan(PUNCT).uniq.length >= 3
- # If there are three or more identical characters in a row in the string.
- w =~ REPEAT
- # Number of uppercase letters greater than lowercase letters, but the word is
- # not all uppercase + punctuation.
- upper = w.scan(UPPER).length
- lower = w.scan(LOWER).length
- upper > lower && (w !~ ACRONYM)
- # All characters are alphabetic and there are 8 times more vowels than
- # consonants, or 8 times more consonants than vowels.
- valid = w.length > 2 && (w =~ ALL_ALPHA) && (w !~ ACRONYM)
- vowels = w.scan(VOWEL).length
- consonants = w.scan(CONSONANT).length
- valid && (vowels > consonants * 8 || consonants > vowels * 8)
- # Four or more consecutive vowels, or five or more consecutive consonants.
- (w =~ VOWEL_4) || (w =~ CONSONANT_5)
Add Comment
Please, Sign In to add comment