# Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Value STATUS ([sxSdh*])
# ? \| multipath
Value PATH_SELECTION ([> |])
# Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-injected
Value ROUTE_SOURCE ([ieclarI])
Value Filldown NETWORK ([A-Fa-f0-9:\.]+\/\d+)
Value NEXT_HOP ([A-Fa-f0-9:\.]+)
Value METRIC (\d+)
Value LOCAL_PREF (\d+)
Value WEIGHT (\d+)
Value AS_PATH (\d+(\s.*?)*)
# Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Value ORIGIN ([ie\?\|&])
Value Filldown VRF (\S+)


Start
  ^BGP\s+routing\s.+VRF\s+${VRF},.+
  ^BGP\s+table\s+
  ^Status:
  ^Path type:
  ^Origin codes:
  ^\s*Network\s+Next Hop\s+Metric\s+LocPrf\s+Weight\s+Path -> Bgp_table
  ^. -> Error

Bgp_table
  #
  # Match first when there is no network, since previous line had it already (compliment and filldown below)
  # Older table format, with blank values parsing not reliable. (cisco_nxos_show_ip_bgp.raw)
  #             Network            Next Hop            Metric     LocPrf     Weight Path
  # Example: *>e10.10.101.4/30     10.10.2.1                                      0 64102 i
  # Example: *>e                   10.10.1.1                                      0 64101 64002 i
  ^\s+${PATH_SELECTION}${ROUTE_SOURCE}\s\s\s{16}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^\s+${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s\s\s{16}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  #
  # Match newer format (cisco_nxos_show_ip_bgp1.raw)
  # Example: * e0.0.0.0/0 1.2.3.4 4294967295 0 12345.102 
  ^\s+${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^\s+${PATH_SELECTION}${ROUTE_SOURCE}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
  ^\s*$$ -> Clearall
  ^BGP\s+routing\s.+VRF\s+${VRF},.+ -> Start
  ^. -> Error

EOF
