------------------------------------------------
On Tue, 4 Feb 2003 14:36:01 -0500 , Ned Cunningham <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I am trying to check for a valid year in a field.
> 
> The data is :
> 
> 02chevy
> 02 chevy
> 2chevy
> chevy
> 
> my regex is as follows but does not work-  
> 
> $newyr = substr($yr[0],0,2);
> 
> if ($newyr =~ /([0-9])/) {
> 

Your regex does work, granted it isn't what you want. Your regex just checks to see if 
there is a digit at all (and then captures it), which is why 2c works but ch does not. 
Probably you want to handle this more like:

if ($yr[0] =~ /(\d\d)/) {
   $newyr = $1;
}
else {
   die 'No year specified';
}

There are many, many other ways to handle this as well, have you considered 4 digit 
years?

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to