Re: Regex for Amateur Radio Callsigns
| From: | Leonard Burton | Date: | Wed, 16 Nov 2005 03:39:19 +0000 |
| Subject: | Re: Regex for Amateur Radio Callsigns | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225890@lists.php.net to get a copy of this message | ||
HI Curt,
Thanks for the reply,
> What does a amateur radio callsign look like? And in what context
> are you trying to parse this callsign?
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 .= "/";
I am still trying to master regexes. Is there a better way to do this?
THanks,
--
Leonard Burton, N9URK
leonardburton@gmail.com
"The prolonged evacuation would have dramatically affected the
survivability of the occupants."