Reference · Australian country module
parseAustralianAddressfunction
Parses an Australian address into its parts, as Australia Post lays one out: the delivery line, then the suburb or
town, the state and the postcode. Reads a unit written 3/12, Unit 3/12, Unit 3, 12 or U3 12; a level
(Level 6, L6, Ground Floor); a lot (Lot 12); a range of numbers (12-14); a building's name on a line of
its own; and the postal deliveries PO Box, GPO Box, Locked Bag, Private Bag, RMB, RSD, RMS, CMB,
CMA, CPA, MS and Care PO. The street type is reported as AS4590's abbreviation (St, Pde, Cres). A state
is written by its code or its name; a trailing Australia is dropped.
Import it
import { parseAustralianAddress } from "@johnmorrisdotca/address-plus/au";
Definition
function parseAustralianAddress(text: string, options?: ParseOptions): ParsedAddress | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The address as one string; commas and line breaks both separate its parts. |
options (optional) | ParseOptions |
|
Returns
ParsedAddress | null
The parts found, with country: "AU", or null when the text is empty or has nothing but a state.
Examples
import { parseAustralianAddress } from "@johnmorrisdotca/address-plus/au";
console.log(parseAustralianAddress("Unit 3/12 Smith St, Parramatta NSW 2150"));
// → {"secUnitType":"Unit","secUnitNum":"3","number":"12","street":"Smith","type":"St","city":"Parramatta","state":"NSW","zip":"2150","zipValid":true,"country":"AU"}{
secUnitType: 'Unit',
secUnitNum: '3',
number: '12',
street: 'Smith',
type: 'St',
city: 'Parramatta',
state: 'NSW',
zip: '2150',
zipValid: true,
country: 'AU'
}What it prints (run when this page was built)