in reply to Need help with perl regexp
use warnings; use strict; while (my $address = <DATA>) { my ($street, $number) = ( $address =~ / \A # start of s +tring ( \w{3} \. \s \w{3} \s \w{3} ) # 'aaa. bbb +ccc' \s # followed b +y a space (?:nr\. \s )? # optional ' +nr. ' \w{3} # 'ddd' (\d+) # 'ddd...' /ix ); print "Street: $street, Number: $number\n"; } exit; __DATA__ aaa. bbb ccc nr. ddd23-56
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with perl regexp
by flaviusm (Acolyte) on Oct 22, 2007 at 19:03 UTC |