简体   繁体   中英

Regex expression to match the string

我有一个需要处理以下正则表达式的要求: - 不得包含任何字母顺序超过 3 个连续字母(通过 - abc、bcd、aabcd、abcdd、abcc、cdee、ghid、stua | FAIL - abcd , bcde, cdef, ghijklm)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM