fork download
  1. function validate1st8NotSame(value)
  2. if value:match("^(.)%1%1%1%1%1%1%1") then
  3. return false
  4. end
  5. return true
  6. end
  7.  
  8. function validate1st8NoSame(value)
  9. if value:sub(1,8):match("(.).-%1") then
  10. return false
  11. end
  12. return true
  13. end
  14.  
  15. print(validate1st8NotSame("aaaaaaaa")) --not valid
  16. print(validate1st8NotSame("aaaaaaab")) --valid
  17. print(validate1st8NotSame("aaaaaaa")) --!you should enforce 8+ charactesr otherwise this is valid
  18.  
  19. print(validate1st8NoSame("abcdefghe")) --valid
  20. print(validate1st8NoSame("abcdefgae")) --invalid
Success #stdin #stdout 0s 4480KB
stdin
Standard input is empty
stdout
false
true
true
true
false