本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · ドイツのモジュール

parseGermanAddress関数

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

Parses an address in Germany into the parts Deutsche Post and DIN 5008 lay out: who it is care of (careOf, from c/o, z. Hd., bei), the part of a building (building: Hinterhaus, Haus B, or a name above the street), a flat (secUnitType and secUnitNum: Wohnung 12), a floor (floorType and floor: Obergeschoss and 2), the street's whole name as written in street (Hauptstraße, Berliner Str., Am Markt), its house number in number (12a, 12-14), a Postfach or Packstation (secUnitType and secUnitNum), the Ortsteil in locality, the place in city, and the postcode in zip with the Land's code in state. The postcode may stand anywhere after the street; D-10115 is read as 10115.

インポート

import { parseGermanAddress } from "@johnmorrisdotca/address-plus/de";

定義

function parseGermanAddress(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 DE, or null when the text is empty or holds nothing that makes it an address.

例

import { parseGermanAddress } from "@johnmorrisdotca/address-plus/de";

console.log(parseGermanAddress("c/o Weber, Hinterhaus, Hauptstraße 12a, 10115 Berlin"));
// → {"careOf":"Weber","building":"Hinterhaus","street":"Hauptstraße","number":"12A","city":"Berlin","state":"BE","zip":"10115","zipValid":true,"country":"DE"}
{
  careOf: 'Weber',
  building: 'Hinterhaus',
  street: 'Hauptstraße',
  number: '12A',
  city: 'Berlin',
  state: 'BE',
  zip: '10115',
  zipValid: true,
  country: 'DE'
}

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

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

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