Skip to content

Instantly share code, notes, and snippets.

@Danjavia
Created August 2, 2017 04:09
Show Gist options
  • Save Danjavia/50108de93abb1bc8b239489ecea8e310 to your computer and use it in GitHub Desktop.
Save Danjavia/50108de93abb1bc8b239489ecea8e310 to your computer and use it in GitHub Desktop.
Sample for Belatrix: Please, copy the code below and paste within chrome dev tools console to show result.
let raw = [
"01 Lima / / ",
"01 Lima / 50 Lima / ",
"01 Lima / 51 Barranca / ",
"01 Lima / 50 Lima / 202 La Molina",
"01 Lima / 50 Lima / 203 San Isidro",
"02 Arequipa / / ",
"02 Arequipa / 63 Arequipa / ",
"02 Arequipa / 64 Caylloma / ",
"02 Arequipa / 63 Arequipa / 267 Cercado"
];
let newItems = [];
raw.map((line, key) => {
let items = line.split(/( [\d]+ |[\d]+|\/)/);
const cleanItems = items.filter((item) => item != '' && item != '/');
newItems.push(cleanItems);
});
console.table(newItems);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment