Last active
December 25, 2015 12:27
-
-
Save maxan/51c6545633b5c1daf8c0 to your computer and use it in GitHub Desktop.
Municípios Brasileiros (da Wikipédia)
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
// Fonte dos municípios: https://pt.wikipedia.org/wiki/Lista_de_munic%C3%ADpios_do_Brasil | |
$('table tbody > tr > td > ul > li').each(function(index, element) { | |
pattern = /([\s\S]*)(\([A-Za-z]{2}\))/; | |
text = $(this).text(); | |
result = text.match(pattern); | |
result.forEach(function (e, i, a) { a[i] = a[i].trim(); }); | |
console.log('INSERT INTO Municipio (Nome, Estado) VALUES (\'' + result[1] + '\', \'' + result[2].replace(/(\()(\w+)(\))/, '$2') + '\');'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Utiliza Jquery!