7.1
2013-01-30

Examples

The following examples may be useful.

Only numbers

The following regular expression accepts only numbers as input:

[0-9]+

The expression step by step:

Dutch zip code

The Dutch zip code consists of four numbers, one space and two uppercase letters (eg 1234 AB).

[0-9]{4}\s[A-Z]{2}

The expression step by step:

Canadian zip codes

Canadian postal codes alternate between letter and number such as L0S 1E0. Some choose not to put in the space. And not every letter is used as the first letter which designates region. The regions are (from east to west, then north): A,B,C,E,G,H,J,K,L,M,N,P,R,S,T,V,X,Y.

\s*[a-ceghj-npr-tvxyA-CEGHJ-NPR-TVXY]\d[a-zA-Z](\s)?\d[a-zA-Z]\d\s*

The expression step by step: