> -----Original Message-----
> From: Kamali Muthukrishnan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 26, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: pattern matching for serial number
> 
> 
> Hi guys :
> I have serial numbers with a pattern : 3 numbers followed by 
> 2 capital letters followed by 3 numbers.
> To validate this -
>   if ($serial !~ m/[0-9]{3}[A-Z]{2}[0-9]{3} )
>       {  # display error ;  }
> I get a syntax error.

In addition to the missing "/" at the end of your regex, note
also that you did not "anchor" your regex. This means that
you will have a sucessful match if the pattern appears anywhere
in the contents of $serial; there may be characters before
or after the pattern. This may or may not be a problem.

This matches:

   123AB456

But so does this

   x&123AB456\n!

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

Reply via email to