fork download
  1. import re
  2. p = re.compile(r'^\s+([\w-]+)\s+.+$', re.MULTILINE)
  3. test_str = "config t\nEnter configuration commands, one per line. End with CNTL/Z.\nn7k(config)# port-profile demo_ethernet\nn7k(config-port-prof)# ?\n bandwidth Set bandwidth informational parameter\n beacon Disable/enable the beacon for an interface\n cdp Configure CDP interface parameters\n channel-group Configure port channel parameters\n delay Specify interface throughput delay\n description Enter port-profile description of maximum 80 characters"
  4.  
  5. print(re.findall(p, test_str))
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
['bandwidth', 'beacon', 'cdp', 'channel-group', 'delay', 'description']