Skip to content

Instantly share code, notes, and snippets.

@maxan
Last active December 25, 2015 12:27
Show Gist options
  • Select an option

  • Save maxan/51c6545633b5c1daf8c0 to your computer and use it in GitHub Desktop.

Select an option

Save maxan/51c6545633b5c1daf8c0 to your computer and use it in GitHub Desktop.
Municípios Brasileiros (da Wikipédia)
// 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') + '\');');
});
@maxan

maxan commented Dec 25, 2015

Copy link
Copy Markdown
Author

Utiliza Jquery!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment