That isn't quite right, you may get better milage with this...

# untested
if ($z =~ /^[a-zA-Z_\-\.][\w\-\.]{2,}$/) {
  # is ok
}
else {
  # failed
}

Yours should also work, except that...

1. \s isn't needed in the first regex since a space would fail in the second
regex anyway.

2. You need to specify the dash (-), it isn't included in \w.

Rob

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 30, 2003 1:30 PM
To: [EMAIL PROTECTED]
Subject: Pattern matching username


Is this doing what it is suppose to and how efficient?

rule
 - valid chars A-z0-9 _ - .
 - cannot start with a digit
 - cannot start with a space
 - must be greater than 3 in length

sub isValidChars
{ my ($z) = @_;
 return length($z) > 3 && $z !~ /^[\d\s]/ && $z =~ /^[\w.]+$/
}

thanks,
-rkl

-- 
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]

Reply via email to