Created
August 10, 2019 16:41
-
-
Save dbalduini/737c1762f3e985df3f0df7bd0b78a247 to your computer and use it in GitHub Desktop.
Gera lista de cidades do Brasil e copia para a area de transferencia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generated from Wikipedia. | |
* Link: https://pt.wikipedia.org/wiki/Lista_de_munic%C3%ADpios_do_Brasil | |
*/ | |
var xs = []; | |
$('.mw-parser-output li').each(function() { | |
xs.push($(this).text()); | |
}); | |
function extract(cidade) { | |
var re = /^([A-Z].*) \(([A-Z]{2})\)/; | |
var a = re.exec(cidade); | |
if (a && a.length > 0) { | |
return { | |
cidade: a[1], | |
uf: a[2] | |
}; | |
} | |
return null; | |
} | |
// Copy to clipboard | |
copy(xs.map(x => extract(x)).filter(a => a !== null)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment