src/Common/CodeIgniter/Libraries/FormValidation.php
public function valid_postcode($str)
    {
        if (!array_key_exists('valid_postcode', $this->_error_messages)) {
            $this->set_message('valid_postcode', lang('fv_valid_postcode'));
        }

        $pattern = '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) {0,1}[0-9][A-Za-z]{2})$/';
        return preg_match($pattern, strtoupper($str)) ? true : false;
    }
public function valid_postcode($str)
    {
        if (!array_key_exists('valid_postcode', $this->_error_messages)) {
            $this->set_message('valid_postcode', lang('fv_valid_postcode'));
        }

        $pattern = '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) {0,1}[0-9][A-Za-z]{2})$/';
        return preg_match($pattern, strtoupper($str)) ? true : false;
    }
public function valid_postcode ( $ str ) { if ( ! array_key_exists ( 'valid_postcode' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_postcode' , lang ( 'fv_valid_postcode' ) ) ; } $ pattern = '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) {0,1}[0-9][A-Za-z]{2})$/' ; return preg_match ( $ pattern , strtoupper ( $ str ) ) ? true : false ; }
Checks if a string is in a valid UK post code format.

@param string $str The form value

@return boolean
Checks if a string is in a valid UK post code format .