> -----Original Message-----
> From: Leonard Burton [mailto:[EMAIL PROTECTED] 
> Sent: 16 November 2005 03:39
> To: php-general@lists.php.net
> 
> Basically here is the regex I used (I am not the best with regexes):
> 
> $pattern = "/^[0-9]?[A-Z]{1,2}[0-9][A-Z]{1,3}/";
> 
> Here are how they look
> W1W
> W1AW
> WA1W
> AD4HZ
> N9URK
> WB6NOA
> 4N1UBG
> 
> I guess this would be better?
> 
> $pattern  = "/^";
> $pattern .= "([0-9][A-Z][0-9][A-Z]{3})|"; //4N1UBG
> $pattern .= "([A-Z][0-9][A-Z]{1,3})|";    //N9URK, W1AW, W1W
> $pattern .= "([A-Z]{2}[0-9][A-Z]{1,3})"; //WB6NOA, AD4HZ, 
> WA1W
> $pattern .= "/";

You should be able to fold the second and third into:

  $pattern .= "/([A-Z]{1,2}[0-9][A-Z]{1,3})/"

It would be harder, if even possible, to merge this with the first form,
due to the requirement for exactly 3 letters vs 1-3; some kind of
complicated look-behind might do it, but I don't think I even want to
try!

Cheers!

Mike
 
------------------------------------------------------------------------
----------------
Mike Ford, Electronic Information Services Adviser, Learning Support
Services,
JG125, The Library, James Graham Building, Headingley Campus, Beckett
Park,
LEEDS, LS6 3QS,     United Kingdom
Tel: +44 113 283 2600 extn 4730    Fax: +44 113 283 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to