Re: match only a-z or 0-9

2002-11-13 Thread John W. Krahn
David Buddrige wrote: > > Alex Cheung Tin Ka wrote: > > > > Could anyone tell me how to make a regular expression for match a string only >[a-z0-9] ? > > [a-z0-9]+ will match a sequence of characters containing one or more of > the set [a-z0-9]. > > If you want to match a line of characters tha

RE: match only a-z or 0-9

2002-11-13 Thread Timothy Johnson
Correction: That should be [a-z0-9]+. (note the plus) -Original Message- From: Timothy Johnson To: 'Alex Cheung Tin Ka '; '[EMAIL PROTECTED] ' Sent: 11/13/02 12:01 AM Subject: RE: match only a-z or 0-9 You've essentially already done it. [a-z0-9] is a char

RE: match only a-z or 0-9

2002-11-13 Thread Timothy Johnson
You've essentially already done it. [a-z0-9] is a character class that includes all characters within that range. So something like this would work: if($string =~ /^[a-z0-9]$/){ print "It's only letters and digits.\n"; }else{ print "There's something else in there.\n"; } -Original Mes

Re: match only a-z or 0-9

2002-11-12 Thread David Buddrige
[a-z0-9]+ will match a sequence of characters containing one or more of the set [a-z0-9]. If you want to match a line of characters that contains NOTHING BUT [a-z0-9] then you could use: ^[a-z0-9]+$ If you want to match a sequence of characters that must start with [a-z] and contain any number