/(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?<path>\/.*)/

To avoid the "leaning toothpick" problem, Perl lets use different match
delimiters, so the above is the same as:
m#(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?<path>/.*)#

I assume you want to capture the IP and the path, right?
if ( $entry =~ m#([\d.]+)\s+(/\S+)# ) {
   my ($ip, $path) = ($1, $2);
   print "IP $ip asked for path $path\n";

On Fri, Oct 25, 2019 at 5:28 AM Илья Рассадин <elcaml...@gmail.com> wrote:

> For example, this regex
>
> /(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?<path>\/.*)/
>
> On 25.10.2019 13:23, Maggie Q Roth wrote:
> > Hello
> >
> > There are two primary types of lines in the log:
> >
> > 60.191.38.xx        /
> > 42.120.161.xx       /archives/1005
> >
> > I know how to write regex to match each line, but don't get the good
> > result with one regex to match both lines.
> >
> > Can you help?
> >
> > Thanks,
> > Maggie
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk

Reply via email to