R12.1 Project Publication-2025Dec23

Parse the Lines By Keyword

Parse the lines containing the specified keywords or variable template (Pattern Sample: LineByKeyword[$confg]: access-list, LineByKeyword[$confg]: standby <%$standby_id%>).
A screenshot of a chatDescription automatically generated

  • The method can be applied to single pattern, paragraph pattern and collector pattern.
  • The scope of selectable variables is all the variables defined in the current pattern. Variable is inserted as a variable template to reference a pre-defined variable.

Example 1: Parse the lines containing one keyword, e.g., parse all access-list to one variable.

  1. Create a new parser, then select CLI Command and retrieve the command show run data on device NY_POPP

  2. Click the down arrow beside + New Pattern, then select Single Variable to create a new single-variable pattern. 

  3. Click + Add More > Parse Lines, then define Parse Line Settings.

    1. Name: Set the name to acl_config.
    2. Select the The line contains keyword option, then input “^access-list”.  
    3. Click Apply
  4. Check the output and click the  icon to save the parser. 

Example 2: Parse the lines containing keywords (insert a variable template). In this example, we will parse acl_config for each access-list id.

  1. Create a new parser, then select CLI Command and retrieve the command show run data on device NY_POPP.

  2. Click + New Pattern > Advanced > Collector to create a new collector pattern. 

  3. Double-click 3 in line 148 to parse the variable access_list  in a collector pattern, then manually change the ID Line to ^access-list $int:access_list.

  4. Click +Add More > Parse Lines to define Parse Line Settings.

    1. Set the new variable name to acl_config
    2. Select The line contains keyword option, then input ^access-list. Click to select $access-list, then continue to input $_dummy. after these settings, a var line LinesByKeyword[$ospf_config]:^access-list <% $access_list %> $_dummy is added. 
    3. Click Apply
  5. Check the output table. 

  6. Click the  icon at the upper-right corner to save the parser.