postal-code

Pattern match a partial British postcode

房东的猫 提交于 2019-12-06 04:18:52
I have this pattern in a php project I inherited. ^(([gG][iI][rR] {0,}0[aA]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))) {0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$ Which works fine for all practical purposes when used to validate a full British postcode (eg LE1 1AA). However I need to tweak it to allow for partial postcodes like LE1, SN5 ect where only the first segment is provided. Can anyone suggest how to make the adjustment? This should do the job ^(([gG][iI][rR

Find all localities/regions of a city

假如想象 提交于 2019-12-06 02:32:47
问题 I have tried to find a lot over the Internet but I am unable to get a perfect utility/API for my requirement. I am looking for a utility that, given a city name, provides all the localities/regions of that city. (Would be great if alongwith the regions, the pincodes of every area/region could also be provided). P.S - I have been wondering if Google Maps, open-street maps provide such data, as their maps are already very data exhaustive and they virtually have every data point in their system?

FInd a US street address in text (preferably using Python regex)

柔情痞子 提交于 2019-12-06 00:45:51
Disclaimer: I read very carefully this thread: Street Address search in a string - Python or Ruby and many other resources. Nothing works for me so far. In some more details here is what I am looking for is: The rules are relaxed and I definitely am not asking for a perfect code that covers all cases; just a few simple basic ones with assumptions that the address should be in the format: a) Street number (1...N digits); b) Street name : one or more words capitalized; b-2) (optional) would be best if it could be prefixed with abbrev. "S.", "N.", "E.", "W." c) (optional) unit/apartment/etc can

Angular ng-pattern regex code for US Zipcodes and Canadian Postal codes [closed]

旧时模样 提交于 2019-12-05 12:12:39
I could anybody help me out? I am looking for some regexp to use to validate US Zip codes and Canadian Postal codes in AngularJS This should work for you: ^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$ http://regex101.com/r/nO4zF5 Remove the ^ and $ anchors if you don't want to match the start and end of the string. When using in Javascript remember that you need to use the / delimiter: if (/^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/.test(str)) { // it's a match! } And directly, as an Angular ng-pattern : ng-pattern="/^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/" 来源: https://stackoverflow.com

i want specific area name provided pincode of that area

只谈情不闲聊 提交于 2019-12-05 05:39:30
问题 I need name of an area and city I pass the postal code as a parameter. For example I tried http://maps.google.com/maps/api/geocode/json?address=382340&components=country:in&sensor=false for a postal code in India. Although this is giving multiple results with irrelevant data. I could get coordinates using the geocode API. I do not need coordinates though, just the area name corresponding to the postal code. How can I achieve this? 回答1: Try this http://maps.google.com/maps/api/geocode/json

php get the first part of postcode

↘锁芯ラ 提交于 2019-12-04 22:09:36
I need to extract the first part of postcode for search calculation using a database. Any ideas?! I need this to implement a search module in the site, which looks out for some relevant information according to the post code. But the database which I am having for post code, it doesnt have second part of the postcode, only the first part is there. Its for UK postcode. So, any ideas?! This will not cover 100% of all possible UK postcodes, but will do for like 99.999% or so :) /** * @param string $postcode UK Postcode * @return string */ function getUKPostcodeFirstPart($postcode) { // validate

i want specific area name provided pincode of that area

折月煮酒 提交于 2019-12-03 20:15:19
I need name of an area and city I pass the postal code as a parameter. For example I tried http://maps.google.com/maps/api/geocode/json?address=382340&components=country:in&sensor=false for a postal code in India. Although this is giving multiple results with irrelevant data. I could get coordinates using the geocode API. I do not need coordinates though, just the area name corresponding to the postal code. How can I achieve this? Try this http://maps.google.com/maps/api/geocode/json?address=india&components=postal_code:400003&sensor=false This returns the correct results, which could be

ZIP / Postal Code + Country to Geo Coordinates

亡梦爱人 提交于 2019-12-03 12:10:59
问题 What is the most complete, precise and reliable way to get the coordinates (latitude / longitude) of a given ZIP / Postal Code of a given country? I need to make a lot of requests, so a high API limit rate (maybe even absent) would be useful. GeoNames dumps would be cool, but it seems to have way too many duplicate coordinates (example) and it also seems that their database is missing some ZIP / postal codes for specific countries. Are there any other (reliable) alternatives? While I was

php extract UK postal code and validate it

核能气质少年 提交于 2019-12-03 09:13:58
I have some text blocks like John+and+Co-Accountants-Hove-BN31GE-2959519 I need a function to extract the postcode "BN31GE". It may happen to not exist and have a text block without postcode so the function must also validate if the extracted text is valid postcode . John+and+Co-Accountants-Hove-2959519 Find below code to extract valid UK postal code. It return array if post code found otherwise empty. <?php $getPostcode=""; $str="John+and+Co-Accountants-Hove-BN31GE-2959519"; $getArray = explode("-",$str); if(is_array($getArray) && count($getArray)>0) { foreach($getArray as $key=>$val) { if

How to get geolocation from a UK postal code

别等时光非礼了梦想. 提交于 2019-12-03 08:46:51
I have a PHP script at the moment which allows users to enter a UK postcode. I was wondering if there was a way I could get their geolocation from the postcode they enter. (Through Google's API or something?) I have tried http://code.google.com/apis/maps/documentation/geocoding/index.html but it requires a full address, whereas I only have a postcode. Help would be appreciated, thanks :) Peter You could check out the Yahoo PlaceFinder API Heres an example URL http://where.yahooapis.com/geocode?q=BL12DD&appid=[yourappidhere] I have used this in the past and found it to be somewhat accurate.