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

INTERSECTION_PATTERNSconstant

The regular expressions and pattern builders the intersection parser uses to find the city and each street with its type.

Import it

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

Definition

const INTERSECTION_PATTERNS: { readonly BASIC_CITY: RegExp; readonly CITY_WITH_COMMA: RegExp; readonly STREET_WITH_TYPE: (directionalPattern: string, streetTypePattern: string) => RegExp; readonly STREET_SIMPLE: (directionalPattern: string) => RegExp; } = {
    BASIC_CITY: /\s+([A-Za-z\s]{1,30})\s*$/,
    CITY_WITH_COMMA: /,\s+([A-Za-z\s]+)$/,
    STREET_WITH_TYPE: (directionalPattern: string, streetTypePattern: string) => new RegExp(`^(?:(${directionalPattern})\\s+)?([^\\s]+(?:\\s+[^\\s]+)*)\\s+(${streetTypePattern})\\b`, "i"),
    STREET_SIMPLE: (directionalPattern: string) => new RegExp(`^(?:(${directionalPattern})\\s+)?(.+)$`, "i"),
} as const

Members

NameTypeDescription
BASIC_CITYRegExp
CITY_WITH_COMMARegExp
STREET_WITH_TYPE(directionalPattern: string, streetTypePattern: string) => RegExp
STREET_SIMPLE(directionalPattern: string) => RegExp

Examples

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

console.log(INTERSECTION_PATTERNS.CITY_WITH_COMMA.exec("Pine St, Tacoma")?.[1]);
// → "Tacoma"
Tacoma

What it prints (run when this page was built)

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