in reply to Re: Need help with perl regexp
in thread Need help with perl regexp

Thanks a lot. It works great. 

The $n is not needed, but I didn't know how to handle the parameters if  "nr." is present or absent.

Replies are listed 'Best First'.
Re^3: Need help with perl regexp
by mwah (Hermit) on Oct 22, 2007 at 19:36 UTC
    The $n is not needed ...

    then the whole expression may be written more compact:

    ... my ($street, $number) = $address =~ /(.+?) # first grou +p (?:\s+ nr \.)? # any number + prefix? \s+ [A-z]+ (\d+) # number fol +lows alpha /xi; print "STREET: $street, NUMBER: $number\n"; ...

    (although it might backtrack more now ;-)

    Regards

    mwa