From 7091033ae1cd7d4aad3314df6987c0deba0dee46 Mon Sep 17 00:00:00 2001 From: Gary Allan <github@gallan.co.uk> Date: Mon, 11 Dec 2023 21:06:57 +0000 Subject: [PATCH] Bugfix: Fix regex for UK postcodes. #3971 Adding a new customer in the UK fails with Invalid Postcode, this is a valid postcode --- functions/classes/class.Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/classes/class.Common.php b/functions/classes/class.Common.php index 9835e99e..643b7e68 100644 --- a/functions/classes/class.Common.php +++ b/functions/classes/class.Common.php @@ -1253,8 +1253,8 @@ class Common_functions { $country = strtolower($country); // set regexes $country_regex = array( - 'united kingdom' => '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i', - 'england' => '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i', + 'united kingdom' => '/^([A-Z][A-HJ-Y]?[0-9][A-Z0-9]? ?[0-9][A-Z]{2}|GIR ?0A{2})$/i', + 'england' => '/^([A-Z][A-HJ-Y]?[0-9][A-Z0-9]? ?[0-9][A-Z]{2}|GIR ?0A{2})$/i', 'canada' => '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z][ ]?[0-9][A-Z][0-9]\\b\\z/i', 'italy' => '/^[0-9]{5}$/i', 'deutschland' => '/^[0-9]{5}$/i', -- GitLab