本文へ移動

address-plusアドレスプラス

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

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

目次

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

parseFrenchAddress関数

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

Parses an address in France (or Monaco, or an overseas department or collectivity, which are written the same way) into the parts La Poste's norm names: who it is care of (careOf), an apartment or a door (secUnitType, secUnitNum), a floor, a staircase, an entrance, the building or residence (building), the number with its extension (numberExtension: bis, ter, a letter), the type of voie in full in type and its name in street (rue de la Paix is Rue and de la Paix), a lieu-dit, a box (BP 12, CS 30001), the commune in city with its arrondissement and CEDEX, and the postcode in zip with the department's code in state. The postcode may stand anywhere after the street; F-75008 is read as 75008.

インポート

import { parseFrenchAddress } from "@johnmorrisdotca/address-plus/fr";

定義

function parseFrenchAddress(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 FR (or MC or a collectivity's code), or null when the text is empty or holds nothing that makes it an address.

例

import { parseFrenchAddress } from "@johnmorrisdotca/address-plus/fr";

console.log(parseFrenchAddress("Résidence Les Lilas, 12 bis rue de la Paix, 75002 Paris"));
// → {"building":"Résidence Les Lilas","number":"12","numberExtension":"bis","type":"Rue","street":"de la Paix","city":"Paris","state":"75","zip":"75002","zipValid":true,"country":"FR"}
{
  building: 'Résidence Les Lilas',
  number: '12',
  numberExtension: 'bis',
  type: 'Rue',
  street: 'de la Paix',
  city: 'Paris',
  state: '75',
  zip: '75002',
  zipValid: true,
  country: 'FR'
}

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

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

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