in reply to Need help with perl regexp
The rest of your regex could use some love too, but this should get you started.
I'd write:
(edited example to be more robust on street names like "33-44th St")my ($street, $number) = $address=~/ ^(.+?) # capture street name \s+ # ignore following whitespace (?:nr\.\s*){0,1} # ignore optional "nr." and trailing w +hitespace \w+? # ignore alphanumerics which come befo +re... (\d+) # capture digits followed by... -\d+ \s* $ # ignore a hyphen, extra digits and en +d of line /x;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with perl regexp
by ikegami (Patriarch) on Oct 22, 2007 at 18:37 UTC | |
by gamache (Friar) on Oct 22, 2007 at 18:50 UTC |