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

SECONDARY_UNIT_PATTERNconstant

A unit at the end of a street line: group 1 is the street before it, group 2 the unit.

Import it

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

Definition

const SECONDARY_UNIT_PATTERN: RegExp = new RegExp(`^(.*?)\\s+((?:${UNIT_TYPE_KEYWORDS})${UNIT_SEPARATOR}${UNIT_VALUE}|(?:lt|lot)[a-z0-9]+|#\\s*[a-z0-9-]+|${ORDINAL_FLOOR.replace("(", "(?:")})\\s*$`, "iu")

Examples

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

console.log(SECONDARY_UNIT_PATTERN.exec("123 Main St Apt 4")?.[2]);
// → "Apt 4"
Apt 4

What it prints (run when this page was built)

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