regex - UK bank sort code javascript reg. expression -


i looking validate 1 of 2 sort codes. have created below expression match 1 of sort codes unsure how match second sort code part of same expression. below regex should match sort code beginning 72 how add expression should match either of 72 plus 04? appreciated.

^[7]{1}[2]{1}[0-9]{4}$ 

thanks, paul

you rewrite current regex as:

^72[0-9]{4}$ 

and make match 6 digit numbers beginning 04, can use or operator | , non-capture group:

^(?:72|04)[0-9]{4}$ 

(?: ... ) non-capture group, limit scope of or 72 , 04.

some sample numbers matches:

721234 041234 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -