Reference · German country module
parseGermanAddressfunction
Parses an address in Germany into the parts Deutsche Post and DIN 5008 lay out: who it is care of (careOf, from
c/o, z. Hd., bei), the part of a building (building: Hinterhaus, Haus B, or a name above the street), a
flat (secUnitType and secUnitNum: Wohnung 12), a floor (floorType and floor: Obergeschoss and 2), the
street's whole name as written in street (Hauptstraße, Berliner Str., Am Markt), its house number in number
(12a, 12-14), a Postfach or Packstation (secUnitType and secUnitNum), the Ortsteil in locality, the place in
city, and the postcode in zip with the Land's code in state. The postcode may stand anywhere after the street;
D-10115 is read as 10115.
Import it
import { parseGermanAddress } from "@johnmorrisdotca/address-plus/de";
Definition
function parseGermanAddress(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 DE, or null when the text is empty or holds nothing that makes it an
address.
Examples
import { parseGermanAddress } from "@johnmorrisdotca/address-plus/de";
console.log(parseGermanAddress("c/o Weber, Hinterhaus, Hauptstraße 12a, 10115 Berlin"));
// → {"careOf":"Weber","building":"Hinterhaus","street":"Hauptstraße","number":"12A","city":"Berlin","state":"BE","zip":"10115","zipValid":true,"country":"DE"}{
careOf: 'Weber',
building: 'Hinterhaus',
street: 'Hauptstraße',
number: '12A',
city: 'Berlin',
state: 'BE',
zip: '10115',
zipValid: true,
country: 'DE'
}What it prints (run when this page was built)