本文へ移動

address-plusアドレスプラス

住所を端末の中で解析・確認・整形・比較し、国のモジュールや任意のフォームの入力欄を使えます。

address-plusは、parse-addressの使い方を広げ、型付きの結果、確認、書式、国のモジュールを加えます。 名前について(英語)

目次

リファレンス · 英国のモジュール

parseUKAddress関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Parses an address in the United Kingdom (or Jersey, Guernsey and the Isle of Man, which share Royal Mail's postcodes) into the parts of Royal Mail's Postcode Address File: a flat or unit (secUnitType, secUnitNum) or a named part of a building (subBuilding), a floor, the building's name, the number, a dependent thoroughfare, the thoroughfare (its name in street, its descriptor in full in type), the dependent localities, the post town in city, a county, and the postcode in zip with the nation it delivers to. The postcode is found wherever it is written and normalised to capitals with one space; BFPO 105 is read as a forces address.

インポート

import { parseUKAddress } from "@johnmorrisdotca/address-plus/gb";

定義

function parseUKAddress(text: string, options?: ParseOptions): ParsedAddress | null

引数

名前型説明
textstring

The address as one string; commas and line breaks both separate its parts.

options (省略可)ParseOptions

useSnakeCase gives snake_case keys; the other options are not used.

戻り値

ParsedAddress | null

The parts found, with country GB (or JE, GY, IM), or null when the text is empty.

例

import { parseUKAddress } from "@johnmorrisdotca/address-plus/gb";

console.log(parseUKAddress("Flat 14, Ziggurat Building, 60-66 Saffron Hill, London EC1N 8QX"));
// → {"secUnitType":"Flat","secUnitNum":"14","building":"Ziggurat Building","number":"60-66","street":"Saffron","type":"Hill","city":"London","zip":"EC1N 8QX","zipValid":true,"nation":"ENG","country":"GB"}
{
  secUnitType: 'Flat',
  secUnitNum: '14',
  building: 'Ziggurat Building',
  number: '60-66',
  street: 'Saffron',
  type: 'Hill',
  city: 'London',
  zip: 'EC1N 8QX',
  zipValid: true,
  nation: 'ENG',
  country: 'GB'
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/address-plus 1.7.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。