Import AddressParse and call it with an address string and an optional configuration object.
By default, the parser uses regular expressions (type: 0). You can also use tree-based lookup (type: 1).
The function returns an object containing the following keys:
province: Province namecity: City namearea: District/County namename: Specific location namedetail: Detailed address informationphone: Extracted phone numberpostalCode: Extracted postal code
import AddressParse from 'zh-address-parse'
const options = {
type: 0, // 0: Regex (default), 1: Tree lookup
textFilter: [], // Fields to pre-filter/clean
nameMaxLength: 4, // Maximum length for Chinese names
extraGovData: {
city: [],
province: [],
area: []
}
}
const parseResult = AddressParse('your address', options)
// parseResult: { province: '', name: '', city: '', area: '', detail: '', phone: '', postalCode: '' }