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

UNIT_TYPE_NUMBER_PATTERNconstant

A unit's designator and value: groups 1 and 2 (apt 123, Apt. #4B), groups 3 and 4 for a lot run together (lt42), group 5 for the value after a bare #.

Import it

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

Definition

const UNIT_TYPE_NUMBER_PATTERN: RegExp = new RegExp(`(?<![\\p{L}\\p{N}])(${UNIT_TYPE_KEYWORDS})${UNIT_SEPARATOR}(${UNIT_VALUE})|(?<![\\p{L}\\p{N}])(lt|lot)([a-z0-9]+)|#\\s*([a-z0-9-]+)`, "iu")

Examples

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

console.log(UNIT_TYPE_NUMBER_PATTERN.exec("Apt. #4B")?.slice(1, 3));
// → ["Apt","4B"]
[ 'Apt', '4B' ]

What it prints (run when this page was built)

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