> -----Original Message-----
> From: Al Hospers [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 03, 2002 1:37 PM
> To: [EMAIL PROTECTED]
> Subject: RE: validation
> 
> 
> > Al> thanks to everyone who responded. it seems that Bob's
> > Al>  /^\d+$/
> >
> > Al> works the best overall for this situation.
> >
> > Beware that this also matches "123\n".  A solution that rejects /\D/
> > will be faster and more accurate and easier to type than a solution
> > that accepts your regex.
> 
> OK... so you suggest = /\D/ by itself?

$var !~ /\D/ is preferred to $var =~ /^\d+$/ because:

  1. The latter matches "123\n", which contains a non-digit
  2. The former is faster, as it can stop looking when it finds a non-digit

My mistake for suggesting the latter. Use the former.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to