Description
Replaces words and phrases in input strings based on a "table" of substitute words/phrases. It checks to see if the content matches target strings in a custom substitution table and if present will then replace the string content with the replacement string value.This can be used to replace long repeated phrases (such as traffic reports) with terse ones to output to a pager or other compact device.
Configuration Variables
replacementListThe string replace list of target and replacement word or phrase pairs. Each odd element of the list is the target string to find and the successive element is the string to replace the target with. The comparison of the target strings will be affected by the two flags defined next.ignoreWhitespace
Set to ignore leading and trailing whitespace in string content, which is false by default.ignoreCase
Set to ignore case of string content for matching, which is false by default.
Product
Matching string content of subproducts will be replaced with the corresponding replacement text. The structure of the product and non-string content are unaffected by this filter.
How it Works
The handler first clones the input product so that any content changes do not affect other agents that may receive the same input product. It then applies a filter to the string content of its input product with the following steps.
- The string content of each subproduct will be looked up in substitution table for a match. Content other than strings are ignored.
- If ignoreWhitespace flag is set then the looked up string will be stripped or leading and trailing whitespace.
- If ignoreCase flag is set then the string will first be converted to lowercase as will all the target strings.
- If the string value matches any defined in the substitution table then it will be replaced with the corresponding replacement text.
Revised: 2 November 1999