For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2008 > match a particular character class with Perl regular expression









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author match a particular character class with Perl regular expression
Jianyun Zhu

2008-01-16, 4:02 am

Hi, guys, I encountered a confusing issue during my work. Here it is:

I wanna judge if the string is only consisted of assii chararters, but
without some special characters, like "\n", "\t".

I know I can do this by using two time of match, but is it possible to match
just once?

Any advice would be appreciated.

Yitzle

2008-01-16, 7:02 pm

if ( $str =~ /^[a-zA-Z0-9]+$/ ) {
# $str has only alpha-numberic characters
}
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com