Ok, strike my previous comments.

My apologies for wasting your time.


----- Original Message -----
From: "Ken" <[EMAIL PROTECTED]>
To: "John Edwards" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:45 AM
Subject: Re: regex matching


> Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character
comes
> before the {}'s?
>
> I ran this code with the following ip:
> 192.168.0.34
> It works fine.
>
> ----- Original Message -----
> From: "John Edwards" <[EMAIL PROTECTED]>
> To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:40 AM
> Subject: RE: regex matching
>
>
> > "To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
> >
> > Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> > example will match an 'IP' that looks like this;
> >
> > 311.497.999.587
> >
> > for instance.
> >
> > The example I gave isn't perfect (and I nicked the essentials of it from
> the
> > Perl Cookbook) but it will at least not match on completely wrong IPs.
> >
> > John
> >
> > -----Original Message-----
> > From: Ken [mailto:[EMAIL PROTECTED]]
> > Sent: 14 June 2001 16:32
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: Re: regex matching
> >
> >
> > \d only matches one digit....here's a way to extract each number from an
> ip:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = <STDIN>;
> > $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> > print "$1\n";
> > print "$2\n";
> > print "$3\n";
> > print "$4\n";
> >
> > Or if you just want the ip from the line:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = <STDIN>;
> > $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> > print "The ip is: $1\n";
> >
> > To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
> >
> >
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, June 14, 2001 9:12 AM
> > Subject: regex matching
> >
> >
> > > i have a basic knowledge of regex but i want to know if there is a
> > > simpler way to pull patterns out of a line.
> > >
> > > if i have a line like:
> > >
> > >       here is a sample with 123.456.123.456 in the middle.
> > >
> > > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > > get only the ip address?
> > >
> > > thanks..
> > >
> > > Brian T. Wallace
> > > Engineer
> > >
> > >
> >
> >
> > --------------------------Confidentiality--------------------------.
> > This E-mail is confidential.  It should not be read, copied, disclosed
or
> > used by any person other than the intended recipient.  Unauthorised use,
> > disclosure or copying by whatever medium is strictly prohibited and may
be
> > unlawful.  If you have received this E-mail in error please contact the
> > sender immediately and delete the E-mail from your system.
> >
> >
> >
>
>

Reply via email to