Your regex did not allow (w2k-server-proxy2) a valid dns name.
I now see how complex it is to match valid ips or dns names.
The more I try to modify the regex to perfection, the more I see
hopholes. So I think it is not worthwhile spending lot of time on this
regex. My script does more than pattern matching, so I will be ok with
the regex I've got so far.
Unfortunately this will also match 999.999.999.999, but I will keep it.
$_ =~ /[^0][\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.][\d]{1,3}$/;
This matches dns to an acceptable extend.
$_ =~ /^\w+[-\w+-?\w+]*\.?\w+?\d*$/ && $_ != /^\d*$|\d{2,}/;
Thanks anyway for your help.
"K.Prabakar" <[EMAIL PROTECTED]> schrieb am 14.10.2004, 06:49:16:
> On Thu, 14 Oct 2004, K.Prabakar wrote:
>
> > On Wed, 13 Oct 2004, Babale Fongo wrote:
> >
> > > K.Prabakar's suggestion looks good but also failed the test:
> > >
> > > "$_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/",
> > >
> > > It will match an invalid dns name like this (host-.domain.com) as a valid.
> > > I'm still working on it, but will welcome any other suggestion.
> > >
> > > Babs
> > >
>
> As "Randal L. Schwartz" pointed out I used character class"[]" in the
> above regex which is wrong. That should be "()" like
>
> this----------> /^\w\w*-?\w+?(\.\w\w*-?\w+?)*$/
> Now it won't match "host-.domain.com" like names.
>
> Other thing is this will allow dns names starting with DEGITS.In that
> case the worst case solution will be
>
> /^[a-zA-Z]\w*-?\w+?(\.[a-zA-Z]\w*-?\w+?)*$/ .
>
> This will allow names like
> "bla-3bla.bla" , "bla-bla" but won't allow "3bla.bla" and "bla.4bla"
> To avoid underscore again the worst case will be to replace \w with
> [-a-zA-Z] in the above expression. That won't look good at all.
>
>
>
> --
> Regards,
> K.Prabakar
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>