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 4What it prints (run when this page was built)