title: PyParsing: Parsing Cisco's "show ip bgp"
body: <p>I am trying to parse a string as below using PyParsing.</p>
  
  <pre>
  R1# show ip bgp
  BGP table version is 2, local router ID is 1.1.1.1
  Status codes: s suppressed, d damped, h history, * valid, > best, i -     internal,
                r RIB-failure, S Stale
  Origin codes: i - IGP, e - EGP, ? - incomplete
  
     Network          Next Hop            Metric LocPrf Weight Path
  <B>> 10.1.1.0/24      192.168.1.2              0             0 200 i</b>
  </pre>
  
  <p>Note that LocPrf value is empty but it can be a number.</p>
  
  <pre><code>ipField = Word(nums, max=3)
  ipAddr = Combine(ipField + "." + ipField + "." + ipField + "." + ipField)
  status_code = Combine(Optional(oneOf("s d h * r")) + "&gt;" + Optional(Literal("i"))
  prefix = Combine(ipAddr + Optional(Literal("/") + Word(nums,max=2)))
  next_hop = ipAddr
  med = Word(nums)
  local_pref = Word(nums) | White()
  path = Group(OneOrMore(Word(nums)))
  origin = oneOf("i e ?")
  </code></pre>
  
  <p>This is the grammar.</p>
  
  <pre><code>g = status_code + prefix + next_hop + med + local_pref + Suppress(Word(nums)) + Optional(path) + origin
  </code></pre>
  
  <p>I just need to parse the Bold line. But this is not parsing it properly. It assigns Weight value to LocPrf.</p>