This is what I use (it may or may not be in the bbdb distribution, I
forget---I think the discussion ended with not checking the zip at
all, at some point in the future). It's in bbdb-com.el.
(defun bbdb-parse-zip-string (string)
(cond ((string-match "^[ \t\n]*$" string) 0)
((string-match "^[ \t\n]*[0-9][0-9][0-9][0-9][0-9][ \t\n]*$" string)
(string-to-int string))
((string-match "^[ \t\n]*\\([0-9][0-9][0-9][0-9][0-9]\\)[ \t\n]*-?[
\t\n]*\\([0-9][0-9][0-9][0-9]\\)[ \t\n]*$" string)
(list (bbdb-subint string 1) (bbdb-subint string 2)))
;; Match zip codes for Canada, UK, etc. (result is ("LL47" "U4B")).
((string-match
"^[ \t\n]*\\([A-Za-z0-9]\\)[ \t\n]*\\([A-Za-z0-9]\\)[ \t\n]*$"
string)
(list (bbdb-substr string 1) (bbdb-substr string 2)))
((string-match "-[^-]-" string)
(error "too many dashes in zip code."))
((string-match "[^-0-9 \t\n]" string)
(error "illegal characters in zip code."))
((string-match "[0-9][0-9][0-9][0-9][0-9][0-9]" string)
(error "too many digits in zip code."))
((< (length string) 5)
(error "not enough digits in zip code."))
(t (error "not a valid 5-digit or 5+4 digit zip code."))))
--
Brendan Kehoe [EMAIL PROTECTED]
Stop the murder! Support dolphin-free networking.