Re: Help me with a regex problem

2019-10-26 Thread Dermot
You might consider using Regexp::Common::net. It provides a convenient set
of functions for matching IP v4, v6 and mac addresses.


https://metacpan.org/pod/Regexp::Common::net

On Fri, 25 Oct 2019 at 19:43, John W. Krahn  wrote:

> On 2019-10-25 3:23 a.m., Maggie Q Roth wrote:
> >   Hello
>
> Hello.
>
> > There are two primary types of lines in the log:
>
> What are those two types?  How do you define them?
>
>
> > 60.191.38.xx/
> > 42.120.161.xx   /archives/1005
>
>  From my point of view those two lines have two fields, the first looks
> like an IP address and the second looks like a file path.  In other
> words I can't distinguish the difference between these two "types".
>
>
> > 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?
>
> Perhaps if you could describe the problem better?
>
>
> John
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Help me with a regex problem

2019-10-25 Thread John W. Krahn

On 2019-10-25 3:23 a.m., Maggie Q Roth wrote:

  Hello


Hello.


There are two primary types of lines in the log:


What are those two types?  How do you define them?



60.191.38.xx/
42.120.161.xx   /archives/1005


From my point of view those two lines have two fields, the first looks 
like an IP address and the second looks like a file path.  In other 
words I can't distinguish the difference between these two "types".




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?


Perhaps if you could describe the problem better?


John

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help me with a regex problem

2019-10-25 Thread Andy Bach
/(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/

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

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 Илья Рассадин  wrote:

> For example, this regex
>
> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>
> 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


Re: Help me with a regex problem

2019-10-25 Thread Benjamin S Pendygraft II
That is a backslash followed by a forward slash. The backslash tells the
regex parser to treat the next character as a literal character. Useful for
matching periods, question marks, brackets, etc.
A period matches any character once and an asterisk matches the previous
character any number of times. .* basically means match everything.

Apologies if this is formatted incorrectly. Sending from my phone.

On Fri, Oct 25, 2019 at 06:37 Maggie Q Roth  wrote:

> what's V.*?
>
> Maggie
>
> On Fri, Oct 25, 2019 at 6:28 PM Илья Рассадин  wrote:
>
>> For example, this regex
>>
>> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>>
>> 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/
>>
>>
>> --
Benjamin Pendygraft


Re: Help me with a regex problem

2019-10-25 Thread X Dungeness
my $n = '[0-9]{1,3}';
if  (  =~ (  m[ (?:$n\.){3} $n \s+ \S+ ]x )
{
   # match
}


On Fri, Oct 25, 2019 at 3:37 AM Maggie Q Roth  wrote:

> what's V.*?
>
> Maggie
>
> On Fri, Oct 25, 2019 at 6:28 PM Илья Рассадин  wrote:
>
>> For example, this regex
>>
>> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>>
>> 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/
>>
>>
>>


Re: Help me with a regex problem

2019-10-25 Thread Maggie Q Roth
what's V.*?

Maggie

On Fri, Oct 25, 2019 at 6:28 PM Илья Рассадин  wrote:

> For example, this regex
>
> /(?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\s+(?\/.*)/
>
> 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/
>
>
>


Re: Help me with a regex problem

2019-10-25 Thread Илья Рассадин

For example, this regex

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

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/