dipendra:Hi there
I am new to Regular expression. Can i get some help with below two regular expression
1 ) **********************************************************************
Maximum length of 9 characters.
Alphanumeric characters only.
Must have at least 4 numeric characters.
Must have no more than 2 alphabetic characters.
The third and fourth characters must be numeric.
This could be done using a couple of successive positive look a heads:
^(?=[a-z0-9]{6,9}$)(?=..[0-9]{2})(?=.*?[0-9].*?[0-9].*?[0-9].*?[0-9])(?=.*?[a-z].*?[a-z]).*$
I used [0-9] and [a-z] (no caps!) to keep the regex more or less readable. You might want to replace those with \p{Alnum} or some other meta character set available in the flavor of regex you're working with.
dipendra:2) ***********************************************************
Maximum length of 25 characters.
Minimum length 2 characters (unless the family name is “O”).
...
Not quite clear what you mean by that.
Something like this?
^(?:O|.{2,25})$
which matches "O" or any string between 2 and 25 characters.
Please take the time to read:
http://regexadvice.com/forums/thread/45439.aspx
Thanks.