adhirath wcities adhirath wcities - 10 months ago 30
Javascript Question

How to saparate house number from full address from world wide using javascript

I am fetching address from all over the world and format for the address is different. What I need is to separate house number from rest of the address and return me house number as a separate element and rest address as a separate using javascript or Jquery.
Here is example of address:

Langstrasse 120, Zürich
1314 Grant Street, San Francisco


Try This

var addr = 'Langstrasse 120, Zürich';
var myA = addr.split(/(\d+)/g);

This will give you the House number from the Address and then replace this number with whole address, You will find the address without house number.

var full_address    = addr.replace(myA[1],"");

your myA[1] will be house number and full_address will be address without House number.