本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · オーストラリアのモジュール

parseAustralianAddress関数

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

Parses an Australian address into its parts, as Australia Post lays one out: the delivery line, then the suburb or town, the state and the postcode. Reads a unit written 3/12, Unit 3/12, Unit 3, 12 or U3 12; a level (Level 6, L6, Ground Floor); a lot (Lot 12); a range of numbers (12-14); a building's name on a line of its own; and the postal deliveries PO Box, GPO Box, Locked Bag, Private Bag, RMB, RSD, RMS, CMB, CMA, CPA, MS and Care PO. The street type is reported as AS4590's abbreviation (St, Pde, Cres). A state is written by its code or its name; a trailing Australia is dropped.

インポート

import { parseAustralianAddress } from "@johnmorrisdotca/address-plus/au";

定義

function parseAustralianAddress(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: "AU", or null when the text is empty or has nothing but a state.

例

import { parseAustralianAddress } from "@johnmorrisdotca/address-plus/au";

console.log(parseAustralianAddress("Unit 3/12 Smith St, Parramatta NSW 2150"));
// → {"secUnitType":"Unit","secUnitNum":"3","number":"12","street":"Smith","type":"St","city":"Parramatta","state":"NSW","zip":"2150","zipValid":true,"country":"AU"}
{
  secUnitType: 'Unit',
  secUnitNum: '3',
  number: '12',
  street: 'Smith',
  type: 'St',
  city: 'Parramatta',
  state: 'NSW',
  zip: '2150',
  zipValid: true,
  country: 'AU'
}

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

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

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