Page 1 of 1

Help with a regexp

Posted: Wed Mar 10, 2004 1:34 pm
by Shujaa
Hi again, need a quick helper with the syntax for regular expressions. Basically I need to match the first 2 letters of a submitted postcode with a list of postcodes that I know are in a certain area (London), to determine that the user is living in London. The list itself is quite long but is sequential, ie:

E1-E18 are all in, as are:
WC1-WC2
EC1-EC4
N1-N22
NW1-NW11
SE1-SE28
SW1-SW20
W1-W14

I just need to build a regexp that can match any of those ranges of values, but I'm a complete newbie at regexps, and can't even figure out how to specify a logical "OR" clause for the regexp to match with... would appreciate any help.

Posted: Wed Mar 10, 2004 2:28 pm
by Weirdan
OR is specified as | character, ie /(something|something_else)/ reads as something or something_else. It's true for both the PCRE and POSIX regexps.