Showing posts with label Regular Expression. Show all posts
Showing posts with label Regular Expression. Show all posts

Saturday, 26 May 2012

UK postal code flat pattern matching regular expression


UK postal code flat pattern matching regular expression:

Patterns:
A9 9AA
A99 9AA
A9A 9AA
AA9 9AA
AA99 9AA
AA9A 9AA

Note:  
A indicate alphabets from A to Z.
9 indicate number from 0 to 9.

Regular Expression = “^(((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Za-z][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Za-z][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))$”

Hope this will help other who wants only pattern matching expression.