vincentarelbundock/pycountrycode — pull request #22 by NilsTycho (2014-07-18 05:51:37+00:00)
Title: Regex updates

Zillions of regex updates and a few other miscellaneous updates.

WARNING: I have *not* tested this regex with pycountrycode. I *have* tested it with R countrycode, after running it through your `prep_data.R` to generate the .rda.

* All of the unit tests I added to countrycode (in R) now pass. This fixes several issues with the Congos, the Yemens, the Netherlands Antilles, and other areas.
* I removed the “match the whole string” catchalls (`.*`) at the end of most regexes. As far as I can tell, they are not necessary in R. In Python, however, I think they will run face-first into issues #17 and #19.
* I did a lot of work with negative and positive lookaheads. A typical regex now looks like this: `^(?!.*a).*b`, where a occurs nowhere in the string and b occurs somewhere in the string. This eliminates the need for lookbehinds. Note that most lookaheads are “anchored” to the beginning of the string, which means the parser only has to check the lookahead from a single location. I think this is supposed to be much more efficient than `(?!.*a).*b`.
* I added half a dozen uses of diacritics, such as `r(e|é)union`. Perhaps this is dangerous. They work on my computer, and is looks OK on github, but you can replace them with something like `.{1,2}` if you like. You might also consider changing the encoding of the .csv. I’m not sure how Python will behave. I did not add diacritics to country names, only to regex.
* A few updated state names to bring them into line with the ISO. The only remaining discrepancies with the ISO is that they have been stripped of diacritics.
* I added ”Bonaire, Sint Eustatius and Saba”.