in reply to Regex for IP and Optional Port

I started wondering how short this could get... I came up with the following:
$inLine =~ m|([\d\.]+)(/(\d*))?\D+([\d\.]+)(/(\d*))?|;
Results are in $1,$3,$4 and $6

Replies are listed 'Best First'.
Re: Re: Regex for IP and Optional Port
by KILNA (Acolyte) on Jan 16, 2002 at 09:54 UTC
    Actually, borrowing some syntax from andye I got:
    $inLine =~ m|([\d.]+)/?(\d*)\D+([\d.]+)/?(\d*)|;
    And the results are even in $1,$2,$3,$4. Wooooo! :)