我想匹配字符串中的連續n(字母數字)字符。正則表達式匹配連續n(字母數字)
其中n = 3
i7g172w2n YES (it has 3 consecutive number)
adab172cd NO (it has 4 consecutive alpha even though it has 3 consecutive number)
aaa172afa YES (it has 3 consecutive number and 3 consecutive alpha)
ab21cd172 YES
abc21a3d3 YES
能有人幫助我。
這是我的正則表達式:(\D(\d{3})\D)|\d([a-z]{3})\d
無法正常工作。
所有有3個連續的字母數字字符。你的意思是 - 只有在正好有3個字母字符或3位數字,或兩者都有匹配的情況下,才匹配,但是都不應該有超過3個相同類型的連續字符? – zwer
這是正確的「如果只有3個字符或3位數字,或兩者,但都不應該有超過3個相同類型的連續字符」謝謝糾正。 –
@JamesSapam:你在用什麼語言? – Rahul