Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi There
I am looking how to create regular expression with if else statement on. what I wanted to create a regular expression which allow only the bellow patterns
VB
ANANNNNN
ANNANNNN
NANNNNNN

where A =[a-z,A-Z]
N=[0-9]
appreciate your help
thanks
Posted

1 solution

Assuming those are just examples and you want anything with that kind of format:
[a-zA-Z]\d+[a-zA-Z]\d+|\d[a-zA-Z]\d+

If you want exactly what you show, then:
[a-zA-Z]\d[a-zA-Z]\d{5}|[a-zA-Z]\d\d[a-zA-Z]\d{4}|\d[a-zA-Z]\d{6}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900