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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to