Value VRF (\S+)
Value RD (\d\S+|<.+>)
Value List INTERFACES ([\w\./-]+)

Start
  ^\s+V[rR][fF]\s+RD\s+Protocols\s+State\s+Interfaces -> VRF
  ^\s+V[rR][fF]\s+Protocols\s+State\s+Interfaces -> VRF_NO_RD
  ^Maximum
  ^\s*$$
  ^. -> Error

VRF
  # match a vrf with interfaces
  # key on the first line of a VRF
  ^\s+\S+\s+(\d\S+|<.+>)\s+\S+\s+(\S+:?\S+(?:\s\S+)*).*$$ -> Continue.Record
  #
  ################# First lines of VRF ###################
  #
  # match first line of vrf, first interface and it is the last interface
  ^\s+${VRF}\s+${RD}\s+\S+\s+\S+:\S+(\s\S+)*,?\s+${INTERFACES}\s*$$ -> Continue
  #
  # match first line of a vrf, first interface and it is not the last interface
  ^\s+${VRF}\s+${RD}\s+\S+\s+\S+:\S+(\s\S+)*,\s+${INTERFACES}, -> Continue
  #
  # match first line of a vrf, second interface and it is the last interface
  # two interfaces displayed per line
  ^\s+\S+\s+\S+(\s\S+)*\s+\S+\s+\S+:\S+(\s\S+)*,?\s+(?:\S+,\s){1}${INTERFACES}\s*$$ -> Continue
  #
  # match first line of a vrf, third interface and it is the last interface
  # three interfaces displayed per line
  ^\s+\S+\s+\S+(\s\S+)*\s+\S+\s+\S+:\S+(\s\S+)*,?\s+(?:\S+,\s){2}${INTERFACES}\s*$$ -> Continue
  #
  # match first line of a vrf, second interface when there are more than two interfaces
  # two or three interfaces displayed per line
  ^\s+\S+\s+\S+(\s\S+)*\s+\S+\s+\S+:\S+(\s\S+)*,?\s+(?:\S+,\s){1}${INTERFACES}, -> Continue
  #
  # match first line of a vrf, third interface when there are more than three Interfaces
  # three interfaces displayed per line
  ^\s+\S+\s+\S+(\s\S+)*\s+\S+\s+\S+:\S+(\s\S+)*,?\s+(?:\S+,\s){2}${INTERFACES}, -> Continue
  #
  ############## Lines that contain state ##################
  #
  # match state only line
  ^\s+(\S+:\S+(?:\s\S+)*)\s*$$
  #
  # match first interface of the line when it also has a state and it is the last interface
  ^\s+(\S+:\S+(?:\s\S+)*)\s+${INTERFACES}?\s*$$ -> Continue
  #
  # match first interface of the line when it also has a state and it is not the last interface
  ^\s+\S+:\S+(\s\S+)*\s+${INTERFACES}, -> Continue
  #
  # match second interface of the line when it also has a state and it is the last interface
  # two interfaces displayed per line
  ^\s+\S+:\S+(\s\S+)*\s+(?:\S+,\s){1}${INTERFACES}\s*$$ -> Continue
  #
  # match third interface of the line when it also has a state and it is the last interface
  # three interfaces displayed per line
  ^\s+\S+:\S+(\s\S+)*\s+(?:\S+,\s){2}${INTERFACES}\s*$$ -> Continue
  #
  # match second interface of the line when it also has a state and it is not the last interface
  # two or three interfaces displayed per line
  ^\s+\S+:\S+(\s\S+)*\s+(?:\S+,\s){1}${INTERFACES}, -> Continue
  #
  # match third interface of the line when it also has a state and it is not the last interface
  # three interfaces displayed per line
  ^\s+\S+:\S+(\s\S+)*\s+(?:\S+,\s){2}${INTERFACES}, -> Continue
  #
  ################# Lines that have whitespace preceding the interface list ####################
  #
  #
  # match first interface of the line when it only has whitespace and it is the last interface
  ^\s+${INTERFACES}\s*$$ -> Continue
  #
  # match first interface of the line when it only has whitespace and it is not the last interface
  ^\s+${INTERFACES}, -> Continue
  #
  # match second interface of the line when it only has whitespace and it is the last interface
  # two interfaces displayed per line
  ^\s+(?:\S+,\s){1}${INTERFACES}\s*$$ -> Continue
  #
  # match third interface of the line when it only has whitespace and it is the last interface
  # three interfaces displayed per line
  ^\s+(?:\S+,\s){2}${INTERFACES}\s*$$ -> Continue
  #
  # match second interface of the line when it only has whitespace and it is not the last interface
  # two or three interfaces displayed per line
  ^\s+(?:\S+,\s){1}${INTERFACES}, -> Continue
  #
  # match third interface of the line when it only has whitespace and it is not the last interface
  # three interfaces displayed per line
  ^\s+(?:\S+,\s){2}${INTERFACES}, -> Continue
  #
  ################## For vrfs without interfaces ###################
  #
  # match vrf line with no interfaces
  ^\s+${VRF}\s+${RD}\s+\S+\s+\S+:\S+(\s\S+)*,?\s+$$
  #
  ################## Unmatched ###################
  ^---+

VRF_NO_RD
  ^\s+\S+\s+\S+\s+(no\s)?routing.*$$ -> Continue.Record
  #
  # no interfaces
  ^\s+${VRF}\s+\S+\s+(no\s)?routing\s+$$ -> Record
  #
  # first line, first interface
  ^\s+${VRF}\s+\S+\s+\S+(\s\S+)?\s+${INTERFACES},?(\s\S+,?)*\s*$$ -> Continue
  # first line, second of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){1}${INTERFACES},? -> Continue
  # first line, third of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){2}${INTERFACES},? -> Continue
  # first line, fourth of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){3}${INTERFACES},? -> Continue
  # first line, fifth of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){4}${INTERFACES},? -> Continue
  # first line, sixth of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){5}${INTERFACES},? -> Continue
  # first line, seventh of multiple interfaces
  ^\s+\S+\s+\S+\s+\S+(\s\S+)?\s+(?:\S+,\s){6}${INTERFACES},? -> Continue
  #
  # line begins with whitespace, first interface
  ^\s+${INTERFACES}, -> Continue
  ^\s+${INTERFACES}$$ -> Continue
  # line begins with whitespace, second interface
  ^\s+(?:\S+,\s){1}${INTERFACES},? -> Continue
  # line begins with whitespace, third interface
  ^\s+(?:\S+,\s){2}${INTERFACES},? -> Continue
  # line begins with whitespace, fourth interface
  ^\s+(?:\S+,\s){3}${INTERFACES},? -> Continue
  # line begins with whitespace, fifth interface
  ^\s+(?:\S+,\s){4}${INTERFACES},? -> Continue
  # line begins with whitespace, sixth interface
  ^\s+(?:\S+,\s){5}${INTERFACES},? -> Continue
  # line begins with whitespace, seventh interface
  ^\s+(?:\S+,\s){6}${INTERFACES},? -> Continue
  #
  # Unmatched
  ^---+