Please help me to create the regular expression for the street address.
conditions are like
1. Only numbers,(/-) and [ABCDFGHJKLMNPRSTV] should allow.
2. Maximum two consecutive characters(letters) are allowed only after slash.
3. Should start with number only(max 4 numbers), rest is an optional if they enter: should follow the above mentioned criteria.
4. Possible combinations are like
12, 1567, 19/A, 123/B,12-45, 124-138, 12-14/A, 14/A-16, 12/A-16/B, 165/2, 123/1,
12-14/2, 14/2-16, 12/2-16/B, 11/A-12/1, 12/1-14/2, 0126/2-3, 125/BA, 345/BA/128,
248/12/A, 123/234/BA, 246/12/A/2
I tried with
"^\d{1,4}([/-]?\d{0,3}?[ABCDFGHJKLMNPRSTV]{0,2}?[/-]?\d{0,3}?
[ABCDFGHJKLMNPRSTVV]{0,2}?[/-]?\d{0,3}?[ABCDFGHJKLMNPRSTV]{0,2}?)$"
this code working for the above mentioned combinations but still allowing other combinations also,
character should not followed by "-(-C is wrong)" it should only followed by** '/'**
and i don't want enter more than 4 digits if its a single string**(Ex:: 1234 is right, now it is allowing 12345....to 13 chars)**
and only two characters allowed if its preceded with '/'(Now 12ABCDABCD.. allowing which is not right).
Please help me to create a proper regular expression, thanks in advance.
[A,B,C...]it includes,too. You can just write[ABCDFGHJKLMNPRSTV].