Last active
December 30, 2015 12:29
-
-
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!
This file contains 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
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