On Sat, Jun 09, 2001 at 06:33:21PM -0500, Karen Cravens ([EMAIL PROTECTED]) wrote:
> On 9 Jun 2001, at 16:21, William wrote:
> 
> >    if (($L) = ($_) =~ m/\b([0-9.0-9.0-9.0-9]+)\b/ ) {
> 
> A valid IP address is going to look like four groups of one to three 
> digits separated by dots.
> 
> So if "one to three digits" is \d{1,3} (\d is the same as [0-9]), the 
> regex is going to want to look something more like
> 
> /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
> 
> Notice the quoted-metacharacter dots, otherwise you'll get wacky 
> matches.
> 
> Now, the \b's are probably rendered moot by greediness, so unless 
> you are trying to avoid picking up "x12.34.56.78" you can take 
> those out.  Someone can probably fine-tune which places don't 
> actually need three digits and whatnot, too.

It can be a bit more complex that that tho'. The first diit in a set of
three can only be 1 or 2, if the first digit is 2 then the second one can
only be 1 to 5, if the second digit is 5 then the third can only be 1 to
5.

Of course, trying to cope withthat makes the regex far more complex and
you might think it's too much extra effort for too little gain :)

Dave...

Reply via email to