This works wrong. for example this is right - ddd, 2ddd, 2d2ddd, w4hh2www and 2dd, 2d2d2d, dd2d, dd2dd2dd2d this is a wrong, but its working not correctly, /^[a-zA-Z0-9]+[a-zA-Z]{2}/ or /^[a-zA-Z0-9]+[a-zA-Z]{3}/
You may try that one: /(^[a-z\d]*[a-z]{3}[a-z\d]*$)|(^\d+$)/i
const src = ['2ttt78','q6n','44aaa78','a8','!bbb9','9c','9ddd','2w2www','2d2d2d', '78'],
pattern = /(^[a-z\d]*[a-z]{3}[a-z\d]*$)|(^\d+$)/i
src.forEach(s =>
console.log(`${s} is valid: `, pattern.test(s)))
.as-console-wrapper{min-height:100%;}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments