in reply to Re: complicated expression
in thread complicated expression

this is p3rldud3 again.

thanks gav,i took your approach, looks good, but it doesnt work correctly for me!

lets get back to some another example input line.

211.46.248.1 /the / directory / is / here/ l:user p:pass port:21

the $path can be long and also have several whitespaces in it. at the first expression, i used a expression to get the path starting at the first "/" and the last "/".

then it should work fine!

would you help me inserting this fix in your code? many thanks!

perldude

Replies are listed 'Best First'.
Re: Re: Re: complicated expression
by perlplexer (Hermit) on Apr 03, 2002 at 13:48 UTC
    my $foo = "211.46.248.1 /the / directory / is / here/ l:user p:pass po +rt:21"; my @bar = $foo =~ /^(\d+\.\d+\.\d+\.\d+) +(.+)(?= l:) +l:(\S+) p:(\S+) + port:(\d+)/; print join ',', @bar; # prints 211.46.248.1,/the / directory / is / here/,user,pass,21

    You may want to qr// the RegEx if you plan to use it inside of a loop while parsing your file.

    --perlplexer
      Very Great! Many thanks to YOU and the other who were helping!
      Greets, Perldude