I am interested to list all the cities of earth which end with the string "video", like "Montevideo"
1 Answer
Get the world-wide cities database from http://download.maxmind.com/download/worldcities/worldcitiespop.txt.gz
Unzip. You should get almost 3.2 million cities.
list=Import[ToFileName[{$HomeDirectory,"Downloads"},"worldcitiespop.txt"],"CSV"][[All,{1,3}]];
Select[list,StringMatchQ[#[[2]],StringExpression[__,"video"] ]&]//TableForm
I've kept the first column, so you can see the country. The last columns contain the coordinates, in case you want to do some geo plots with that.
But that takes several seconds and leaves out solutions like "...vidéo" and "Monte Video" and "... Montevideo Chico", which the o/p is presumably interested in as well. The above takes "end with the string 'video'" literally. You're must faster not using M at all for this and get all 41 cases (not just 35, as above) with a one-liner in less than a second:
LC_CTYPE=iso-8859-1 grep video worldcitiespop.txt
Select[CityData[], StringMatchQ[CommonName[#], "*video"] &]
. $\endgroup$