in reply to UK postcode regex
#!/usr/bin/perl -l $zipadidoda = 'le12 ogx'; print "In: $zipadidoda"; if( $zipadidoda =~ s/^([A-Z]{1,2}\d{1,2}[A-Z]?)\s?(O|\d)([A-Z]{2})$/uc +("$1 ".(0+$2).$3)/ie ) { print "Out: $zipadidoda"; } else { print "Invalid zipcode"; }
You wanted a single re, so you got one!
Or is the 'e' modified considered cheating?
:)
Update: removed redundant quotes
Update: and fixed the space after a tip from ww
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UK postcode regex
by Roy Johnson (Monsignor) on Apr 21, 2005 at 14:10 UTC | |
|
Re^2: UK postcode regex
by ww (Archbishop) on Apr 21, 2005 at 15:35 UTC | |
by Gilimanjaro (Hermit) on Apr 22, 2005 at 18:11 UTC |