本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · /in

parseIndianAddress関数

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

Parses an address in India into the parts India Post lays out: who it is care of (careOf, from C/o, S/o, D/o, W/o), a building's name (building), the flat or shop (secUnitType and secUnitNum: Flat 4B), the floor, the house number (number: 12, 12/3, 12-A) and the street as written (street: MG Road), a landmark (place: Near City Mall), the area in locality, the city in city, the PIN code in zip (560038, with no space) and the state's code in state (KA), as written or from the PIN code. The state and the city stand before the PIN code.

インポート

import { parseIndianAddress } from "@johnmorrisdotca/address-plus/in";

定義

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

例

import { parseIndianAddress } from "@johnmorrisdotca/address-plus/in";

console.log(parseIndianAddress("12 MG Road, Indiranagar, Bengaluru, Karnataka 560038"));
// → {"number":"12","street":"MG Road","locality":"Indiranagar","city":"Bengaluru","state":"KA","zip":"560038","zipValid":true,"country":"IN"}
{
  number: '12',
  street: 'MG Road',
  locality: 'Indiranagar',
  city: 'Bengaluru',
  state: 'KA',
  zip: '560038',
  zipValid: true,
  country: 'IN'
}

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

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

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