commerceguys/addressing

PostalCodeHelper::match() doesn't accept operator modifiers on regular expressions

ekes opened this issue · 0 comments

ekes commented

Example:

PostalCodeHelper::match('ze1 1aa', '', '/ZE[0-9]/i') won't work because

if (substr($rule, 0, 1) == '/' && substr($rule, -1, 1) == '/') {
checks for a regex beginning with / and ending with /.

The only solution I can think of at the moment is to change to:

        $match = preg_match($rule, $postalCode);
        if ($match === FALSE) {
            $match = in_array($postalCode, self::buildList($rule));
        }

Don't know if that would be acceptable?