Regex Parsing different types of lines
Hi, I am trying to parse a BGPO route table export
Network Next Hop Metric LocPrf Weight Path
* 3.0.0.0 131.103.0.2 0 1225 1239 701 80 ?
* 205.238.48.3 0 2914 1280 701 80 ?
* 158.43.206.96 0 1849 702 701 80 ?
* 204.212.44.129 1 0 234 1225 1239 701 80 ?
* 194.68.130.254 0 5459 5413 701 80 ?
* 144.228.240.93 4 0 1239 701 80 ?
* 204.70.4.89 0 3561 701 80 ?BGP Full Route Parse Only.knwf
the file is in data folder within the workflow, it has 82 lines and at least 4-5 types of lines. what is the best practice, I am trying to find the perfect regex for the whole thing but my regex knowledge is all about what I have done so far.
the full route has also a weird format, with fixed lengths, number of spaces change according to the previous fields length though.
anyways, your recommendations are appreciated
PS : the regex I came up with in 2 hours is as follows
^\s+(?[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/[1-3][0-9]{1,2}|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\s+(?<next_hop>[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\s+(?\d+)\s+(?<local_pref>\d+)\s+(?\d+)\s+(?.)\s+(?\w|?)$