in reply to Re: String validation
in thread String validation
Since the OP wants four alphanumerics (and they are merely *likely* to arrive in lowercase), we'll use \w.if ($string =~ m!^(\w{4})$!) { $string =~ tr/[a-z]/[A-Z]/; # or $string = uc $string; # do something } else { # do some error }
The reason I suggested using tr/// instead of uc is that, in my testing, uc() failed on a scalar starting with a digit. Now it seems to work correctly. Let's go back to:
if ($string =~ s!^(\w{4})$!uc($1)!e) { # do something } else { # do some error # print "Location: $error_url" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: You're right...
by btrott (Parson) on Mar 25, 2000 at 02:36 UTC |