Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · Parsing, formatting and shared types

parseParentheticalfunction

Takes words in parentheses out of an address, such as (Rear Entrance).

Import it

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

Definition

function parseParenthetical(text: string): { secondary: string | undefined; remaining: string; }

Parameters

NameTypeDescription
textstring

The address text.

Returns

{ secondary: string | undefined; remaining: string; }

The words in the parentheses (undefined when there are none) and the text without them.

Examples

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

console.log(parseParenthetical("123 Main St (Rear Entrance)"));
// → {"secondary":"Rear Entrance","remaining":"123 Main St"}
{ secondary: 'Rear Entrance', remaining: '123 Main St' }

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.