Comments (6)
Hi Ben. Yep, I will take a look and see if I'm able to make the change.
from libaddressinput.
I made a quick script to find all numbers on the page, the gist is here.
The table on https://en.youbianku.com/Bahrain does seem to match this 1-12 range, so the following regexp would suffice:
(?:\d|1[0-2])\d{2}
from libaddressinput.
@roelofr When I initially looked at the RegEx I too thought it would be okay but I had a play around and it seems to be ineffective for postcodes greater than 999: https://regex101.com/r/39cZU1/1/
I believe ^(1[0-1][0-9]{2}|12[0-1][0-6]|[1-9][0-9]{2}|10[1-9])$
might be a better solution: https://regex101.com/r/9nASya/1
from libaddressinput.
I believe ^(1[0-1][0-9]{2}|12[0-1][0-6]|[1-9][0-9]{2}|10[1-9])$ might be a better solution
This is very expressive for a regex, but mostly, it seems the Google API doesn't return start or end markers, possibly to allow finding postal codes in longer strings.
The pattern I posted matches 2103 matches 103
, and ignores the 2
. How could I miss that, thanks for the correction 👍
So, to fix this, we probably need to check for word markers or EOLs.
Since the last two digits are always required, I tried keeping them out of the alternate match.
So, my v2 would be:
(?:^|\b)(?:1[0-2]|[1-9])\d{2}(?:$|\b)
I ran it again your pattern, and added a 012
, which should be invalid too. Results are here.
Small edit: made all groups non-capturing groups.
from libaddressinput.
(?:^|\b)(?:1[0-2]|[1-9])\d{2}(?:$|\b)
Looks good to me! I'd be more than happy with that being implemented.
from libaddressinput.
@sockix @sebsg are you able to assist with this change?
from libaddressinput.
Related Issues (20)
- Ireland postcode should be on its own line HOT 1
- Cambodia zip format is wrong
- Update order of Taiwan's Subdivision (City/County)
- Incorrect ISO codes for Iran
- Philippines provinces renamed HOT 1
- Dutch (NL) postal code regex matches invalid values HOT 2
- [Question] Are there any specific license restrictions on accessing the chormium-i18n.appspot.com data? HOT 1
- Error in Austrailia territory data HOT 1
- Make admin1 required in Australia and Turkey
- Erroneous sorting codes in French territories
- sub-region keys show as strikethrough text in wiki
- Spanish address format
- Wrong state_name_type for France
- aapt start failed on my Mac.
- Add non geographic UK Postcodes
- Add missing Brazilian City
- Taiwan's locality_name_type
- Street address line 2 does not have a field name (fails accessibility requirements) HOT 1
- Ireland requires addressline1, locality, subdivision HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libaddressinput.