I have a requirement that need to handle the regex expression for below: -must not contain any of Alphabets in sequence more than 3 consecutive letters (PASS - abc, bcd, aabcd, abcdd, abcc, cdee, ghid, stua | FAIL - abcd, bcde, cdef, ghijklm)
Asked
Active
Viewed 98 times
1 Answers
0
It is a little long but I think this is what you are looking for:
\w*((abcd)|(bcde)|(cdef)|(defg)|(efgh)|(fghi)|(ghij)|(hijk)|(ijkl)|(jklm)|
(klmn)|(lmno)|(mnop)|(nopq)|(opqr)|(pqrs)|(qrst)|(rstu)|(stuv)|(tuvw)|(uvwx)|
(vwxy)|(wxyz))\w*
this pattern matches all failing strings. The idea is simple: if a string has a sequence with 4 letters in a row is invalid.

Vasilis Antonakis
- 31
- 3
-
what about the regex,if we consider the capital letters?then it will be too big – Abhi Oct 17 '17 at 09:03
-
it depends if you consider ABcD different from ABCD or abcd or AbCD :) depending your requirement can get very long... if you just need to ignore casing you can use the i flag: /regex/i – Vasilis Antonakis Oct 18 '17 at 09:59
-
check this out: https://stackoverflow.com/questions/24395542/regex-ignore-case :) – Vasilis Antonakis Oct 18 '17 at 10:03