I'm trying to pick out post codes from an array. I am using the post office's regex to find the matches.
$postcodeRegex = "/(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})/";
foreach( $content as $key => $line ){
if( preg_match($postcodeRegex, $line, $matches) !== false ) {
$points[] = $key;
}
}
But preg_match keeps is producing false positives. For example the line below is shown as a match.
HYPERLINK "mailto:email@address.com" email@address.com
My regex skills are very poor. How do i cut down on these false positives?
thanks
edit, a sample of elements in the array:
[2] => Firstname lastname
[6] => 99 Example Street, Example Town, Example City, EX4 3PL
[8] => HYPERLINK "mailto:email@address.com" email@address.com
[10] => 07712 345678
[16] => KEY SKILLS
[18] => Technical Skills
[20] => Microsoft Outlook
[22] => Microsoft Word
[24] => Microsoft Excel