Skip to content

Instantly share code, notes, and snippets.

@ben-bradley
Last active December 30, 2015 12:29
Show Gist options
  • Save ben-bradley/7829875 to your computer and use it in GitHub Desktop.
Save ben-bradley/7829875 to your computer and use it in GitHub Desktop.
This bit of JavaScript regex will parse the interfaces out of an entire Cisco IOS config!
var config = fs.readFileSync('configFile.txt').toString();
var interfaces = config.match(/interface .+[\r]*\n [\s\S]+?[^\ ]!/g);
console.log(interfaces):
/*
[
"interface Vlan1\n description ...\n!",
"interface Vlan2\n description ...\n!",
...
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment