Guest User

Untitled

a guest
Jun 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. ALNUM = /[a-z0-9]/i
  2. PUNCT = /[^a-z0-9\s]/i
  3. REPEAT = /(.)\1{2,}/
  4. UPPER = /[A-Z]/
  5. LOWER = /[a-z]/
  6. ACRONYM = /^[A-Z]+('?s|[.,])?$/
  7. ALL_ALPHA = /^[a-z]+$/i
  8. CONSONANT = /[bcdfghjklmnpqrstvwxz]/i
  9. VOWEL = /[aeiouy]/i
  10. CONSONANT_5 = /[bcdfghjklmnpqrstvwxz]{5}/i
  11. VOWEL_4 = /[aeiouy]{4}/i
  12.  
  13. # More than 20 bytes in length.
  14. w.length > 20
  15.  
  16. # More punctuation than alpha numerics.
  17. w.length > 2 && (w.scan(ALNUM).length < w.scan(PUNCT).length)
  18.  
  19. # Ignoring the first and last characters in the string, if there are three or
  20. # more different punctuation characters in the string.
  21. w[1...-1].scan(PUNCT).uniq.length >= 3
  22.  
  23. # If there are three or more identical characters in a row in the string.
  24. w =~ REPEAT
  25.  
  26. # Number of uppercase letters greater than lowercase letters, but the word is
  27. # not all uppercase + punctuation.
  28. upper = w.scan(UPPER).length
  29. lower = w.scan(LOWER).length
  30. upper > lower && (w !~ ACRONYM)
  31.  
  32. # All characters are alphabetic and there are 8 times more vowels than
  33. # consonants, or 8 times more consonants than vowels.
  34. valid = w.length > 2 && (w =~ ALL_ALPHA) && (w !~ ACRONYM)
  35. vowels = w.scan(VOWEL).length
  36. consonants = w.scan(CONSONANT).length
  37. valid && (vowels > consonants * 8 || consonants > vowels * 8)
  38.  
  39. # Four or more consecutive vowels, or five or more consecutive consonants.
  40. (w =~ VOWEL_4) || (w =~ CONSONANT_5)
Add Comment
Please, Sign In to add comment