re = /^(?!.*?([a-z0-9])(?:.*?\1){2})(?=.*?[a-z])(?=.*?[0-9])(?!.*?(?:0(?:123|987)|1234|2345|3(?:456|210)|4(?:567|321)|5(?:678|432)|6(?:789|543)|7(?:890|654)|8765|9876))(?!.*?(?:abcd|bcde|cdef|d(?:efg|cba)|e(?:fgh|dcb)|f(?:ghi|edc)|g(?:hij|fed)|h(?:ijk|gfe)|i(?:jkl|hgf)|j(?:klm|ihg)|k(?:lmn|jih)|l(?:mno|kji)|m(?:nop|lkj)|nmlk|onml|ponm|rstu|stuv|tuvw|u(?:vwx|tsr)|v(?:wxy|uts)|w(?:vut)|xwvu|yxwv))[a-pr-y0-9]{8}$/mix
str = '12345678
asfkd2ls
abcd12js
ibicid13
I need a regex to validate a password. The constraints are :
-Maximum Embedded Spaces: 0
-Minimum Length: 8
-Maximum Length: 8
-Must not contain letters: Q, q, Z, z
-Maximum Occurrences of one Character/Number: 2
-Maximum Repetitive Character/Number: 2
-Maximum Sequential Character: 3
-Maximum Special Character: 0
-Minimum Alphabet: 1
-Minimum Numbers: 1
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html