R12.1-2025Jul03
Text Replacement
Text replacement is a flexible method to automate text preprocessing before parsing. When you want to search and replace any string in the raw text, you can define a text replacement.
Text replacement is defined at two levels:
- Format level: search and replace a string in the whole range of sample text in one format.
- Pattern level: You can define multiple patterns in a single format. Text replacement can be defined for an individual pattern. The system searches for and replace text within the specified range that matches the parser definition of that pattern.

Text Replacement Entrance
When defining a text replacement, you can add one or multiple replacement rules using either of the following entry points:
- Format-level replacement: Click Define Replacement from the Format drop-down menu. In the pop-up window, specify the search and replacement rules.
- Pattern-level replacement: Click Define Replacement from the Pattern drop-down menu. In the pop-up window, specify the search and replacement rules.
![]() | Note: The settings and logics for defining text replacement from the two entrances are the same. |
Use Cases of Text Replacement
- Form a Table Header Line
When a device command output looks similar to a standard table format but only misses a table header line, you can define text replacement to replace the line of text ahead of the table data with a customized table header line. This twist allows you to continue to define a Table Parser to parse the table data. - Fill Up Table Headers
When one or more table headers are missing in the sample text, using a Table Parser directly will lose the data of those columns. - Rename Duplicate Table Header
When two table headers have the same name, the latter header cannot be parsed.
To resolve this issue, ensure that each table header has a unique name. You can do this by replacing the line containing the duplicate headers with a new line that uses distinct header names. - Adjust table column width
Sometimes the table headers are not aligned with data cells and cannot be parsed by a Table Parser. For example, the alignment gap between table headers and cells causes an incorrect parsed result. - Translate Interface Name
Sometimes interface names in the raw text are irregular and cannot be further used before manual processing.
The following is an example of searching and replacing interface name with a full interface name.
- Retrieve command data show interface status on the device BJ_L2_Core_3, then select several lines from the sample text to parser the table. The interface name is short name in the parsed results.
- Click Define Replacement from the Format menu.
- In the pop-up window, define the settings to change the short name (Fa) to long name (FastEthernet).
- Click +Add Row, then set to replace Fa with FastEthernet. The options are described below:
- Find What - the text you are searching for in the given range.
- Match Whole Word - once enabled, searches will only match if the result is a whole word, e.g., a search for “FastEthernet” will not return “FastEthernet1/2”.
- Match Case - once enabled, search terms are case-sensitive, e.g., a search for “ethernet” will not return “Ethernet”.
- Regular Expression - once enabled, search terms will use the regular expression engine to find complex patterns in the text; otherwise, search terms will be interpreted literally.
- Replace With - the text that will replace what is matched.
- Replace All Matches - replace all matches in the text scope.
- Replace First Only - replace the first match only.
- Find What - the text you are searching for in the given range.
- Click Preview, you can preview the changes in the lower part of this window.
- Click OK to close this window, then you can see the changed results in the output area.
- Click +Add Row, then set to replace Fa with FastEthernet. The options are described below: