I have a textbox where i will be entering values into textbox, my regular expression should validate for
It should allow 4 characters should not exceeding more than that, it should not allow numbers and special characters , and my characters should not be duplicate for example it should allow ABCD , and should not allow AABD or ABCB
How about this?
See it here online on Regexr
I used the modifier
i(IgnoreCase). You can add to the character class[a-z]any character you want to allow.Each character is matched by
([a-z])stored in the capture group 1. The negative lookahead(?!.*\1))checks for every character if it is repeated somewhere else in the string.{1,4}allows from 1 to 4 characters. I am not completely sure about your spec here, if you want to have exactly 4 then change it to{4}