Please see below examples which needs to be satisfied with the regular expression.
Rule : 4-12 alphanumeric characters or special characters (~!@$%&*_+) at least one letter, no spaces
test ---------This is Valid
test@2 ---------This is Valid
test2 ---------This is Valid
2222 ---------This is NOT Valid
2222@ ---------This is NOT Valid
@2222 ---------This is NOT Valid
test user2 ---------This is NOT Valid
testUser ---------This is Valid
testUser@2 ---------This is Valid
testUser2 ---------This is Valid
testUser.2 ---------This is NOT Valid
Please see below examples which needs to be satisfied with the regular expression.
Rule : 4-12 alphanumeric characters or special characters (~!@$%&*_+) at least one letter, no spaces
test ---------This is Valid
test@2 ---------This is Valid
test2 ---------This is Valid
2222 ---------This is NOT Valid
2222@ ---------This is NOT Valid
@2222 ---------This is NOT Valid
test user2 ---------This is NOT Valid
testUser ---------This is Valid
testUser@2 ---------This is Valid
testUser2 ---------This is Valid
testUser.2 ---------This is NOT Valid
Share
Improve this question
edited Apr 1, 2014 at 19:38
Gyhth
1,1659 silver badges22 bronze badges
asked Apr 1, 2014 at 19:36
Pawan PinjarkarPawan Pinjarkar
11 gold badge1 silver badge1 bronze badge
2
- 1 What have you tried so far? – Shreyos Adikari Commented Apr 1, 2014 at 19:37
- A tool like this helps you test as you go: regexpal. – DrLivingston Commented Apr 1, 2014 at 19:40
1 Answer
Reset to default 0This might work
/(?! )(?=.*[a-zA-Z])[a-zA-Z~!@$%&*_+]{4,12}/g
DEMO