Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^\s*(?:(?:(?<A_Addition_to_address_1>.*?),\s*)?(?:No\.\s*)?(?<A_House_number_1>\p{N}+[a-zA-Z]?(?:\s*[-\/\p{P}]\s*\p{N}+[a-zA-Z]?)*)\s*,?\s*(?<A_Street_name_1>(?:[a-zA-Z]\s*|\p{N}\p{L}{2,}\s\p{L})\S[^,#]*?(?<!\s))\s*(?:(?:[,\/]|(?=#))\s*(?!\s*No\.)(?<A_Addition_to_address_2>(?!\s).*?))?|(?:(?<B_Addition_to_address_1>.*?),\s*(?=.*[,\/]))?(?!\s*No\.)(?<B_Street_name>\S\s*\S(?:[^,#](?!\b\p{N}+\s))*?(?<!\s))\s*[\/,]?\s*(?:\sNo\.)?\s+(?<B_House_number>\p{N}+\s*-?[a-zA-Z]?(?:\s*[-\/\p{P}]?\s*\p{N}+(?:\s*[-a-zA-Z])?)*|[IVXLCDM]+(?!.*\b\p{N}+\b))(?<!\s)\s*(?:(?:[,\/]|(?=#)|\s)\s*(?!\s*No\.)\s*(?<B_Addition_to_address_2>(?!\s).*?))?)\s*$
/
gmu

Description

Uses ECMAScript to parse the number and street from a street address.

Submitted by Wiktor Stribiżew - 3 years ago