Answer the question
In order to leave comments, you need to log in
How to find the last part of an address?
There is a regular expression that looks for the part of the address string that matches the house number:
((?<!(д(ом)?|стр(оение)?|/|-)\.?\s*\d*)\d+((,?\s*(к(ор(п(ус)?)?)?\.?)\s*\d+)|(\s*[а-я])|(\s*/\s*\d+))?\s*$)
const addr = 'Россия, Республика Татарстан, Казань, улица Бутлерова, 41';
const regEx = new RegExp('((?<!(д(ом)?|стр(оение)?|/|-)\.?\s*\d*)\d+((,?\s*(к(ор(п(ус)?)?)?\.?)\s*\d+)|(\s*[а-я])|(\s*/\s*\d+))?\s*$)');
const beginStr = addr.match(regEx);
console.log('addr', addr)
console.log('regEx', regEx)
console.log('beginStr', beginStr)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question