go ahead... be a heretic | |
PerlMonks |
•Re: Checking for single digitby merlyn (Sage) |
on May 06, 2003 at 02:03 UTC ( [id://255785]=note: print w/replies, xml ) | Need Help?? |
Hmm. A lot of answers in this thread give something like
/^\d$/, but that's wrong, because that
also matches things like "1\n".
You need to use /\A\d\z/, which forces beginning of string and end of string, not $ which means end of string, or just before a newline at the end of string. -- Randal L. Schwartz, Perl hacker
In Section
Seekers of Perl Wisdom
|
|