freelanceprogrammers.org Forum Index » Perl

determine whether a field is numeric, alpha or alphanumeric


View user's profile Post To page top
junoon_hai_m... Posted: Sat May 21, 2005 10:17 am


Joined: 27 Apr 2005

Posts: 4
determine whether a field is numeric, alpha or alphanumeric
is their a function or way to determine whether a field, or variable
for that matter, is numeric, alpha or alphanumeric?
thanks in advance
Reply with quote
Send private message
View user's profile Post To page top
paulalapatt Posted: Sun May 22, 2005 5:03 pm


Joined: 06 Apr 2005

Posts: 12
determine whether a field is numeric, alpha or alphanumeric
> is their a function or way to determine whether a field, or variable
> for that matter, is numeric, alpha or alphanumeric?
> thanks in advance

Yes you can use regular expressions for that

--- sample code ---

$ID = 2552399;
if($ID =~ /[d]+/) {
print qq{This is a digit};
}




________________________________________
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
 
• To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
 
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Reply with quote
Send private message
View user's profile Post To page top
georges_toullat Posted: Sun May 22, 2005 10:39 pm


Joined: 22 May 2005

Posts: 3
determine whether a field is numeric, alpha or alphanumeric
Hi,

You can explore the following idea:

$x=11;
$y="This a string";

print "$x is a number" if !($x & ~$y);
print "$y is a string " if ($x & ~$y);

Regards,

Georges


-------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 € TTC/min)
Minitel: 3615 NETCOURRIER (0,16 € TTC/min)
Reply with quote
Send private message
View user's profile Post To page top
whinnim Posted: Tue May 24, 2005 1:19 pm


Joined: 07 Mar 2005

Posts: 4
determine whether a field is numeric, alpha or alphanumeric
junoon_hai_mujhe wrote:
> is their a function or way to determine whether a field, or variable
> for that matter, is numeric, alpha or alphanumeric?
> thanks in advance
perldoc -q "How do I determine whether a scalar is a
number/whole/integer/float?"
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help