The expression you're using will match letters at the beginning of a string,
but will allow for other stuff at the end. To avoid this, put a $ at the
end of your regex. Also, [a-zA-Z] can be replaced with \w, which does the
same thing.
So, you have
$name =~ /^\w+$/
-----Original Message-----
From: Stephanie Stiavetti [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 3:47 PM
To: '[EMAIL PROTECTED]'
Subject: regexp issues
I need to make sure that a field contains ONLY letters... and this is the
regular expression I'm using:
$name=~/^[a-zA-Z]+/
it doesn't seem to be working in the test script that I wrote:
#!/usr/bin/perl -w
print "what's your name?";
$name=<STDIN>;
chomp $name;
$flag=$name=~/^[a-zA-Z]+/;
if (!$flag) {
print "sorry... try again.\n";
}
else {
print "woo hoo!\n";
}
what am I doing wrong? also, will said regular expression accept foreign
characters as letters, like an umlaut? (ö)
`°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º
Stephanie J. Stiavetti
Production Tools
Industrial Light + Magic
415-448-3213 <-|-> [EMAIL PROTECTED]
`°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º
And then the day came when the risk to
stay tight in a bud became more painful
than the risk it took to blossom.
--Anais Nin
`°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º¤,ô¿ô,¤º°``°º
--
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]