public static function postal($check)
{
$pattern = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
return (bool) preg_match($pattern, $check);
}
/** * test the postal method of GbValidation * * @return void */ public function testPostal() { $this->assertTrue(GbValidation::postal('DT4 8PP')); $this->assertFalse(GbValidation::postal('DT4-8PP')); }