Reference · Parsing, formatting and shared types
parseInformalAddressfunction
Reads an address written loosely, as a fallback when parseLocation finds no street address: a description such as
Downtown near City Hall is kept whole as the street, with any ZIP code after it.
Import it
import { parseInformalAddress } from "@johnmorrisdotca/address-plus";
Definition
function parseInformalAddress(address: string, options?: ParseOptions): ParsedAddress | null
Parameters
| Name | Type | Description |
|---|---|---|
address | string | The address as one string. |
options (optional) | ParseOptions | How to parse (see |
Returns
ParsedAddress | null
The street and the ZIP code it could find, or null when the text is empty.
Examples
import { parseInformalAddress } from "@johnmorrisdotca/address-plus";
console.log(parseInformalAddress("Downtown near City Hall, Springfield IL 62701"));
// → {"street":"Downtown near City Hall","zip":"62701","country":"US"}{ street: 'Downtown near City Hall', zip: '62701', country: 'US' }What it prints (run when this page was built)