Class StringReplacer |
This class prebuilds some objects to make wholesale substring replacements more efficient. The constructor takes a table mapping strings to their replacements. The method replace(s) then returns a copy of string s with all substrings found in the table with the corresponding replacement string.
StringReplacer is most useful when you have a lot of replacements to perform across a lot of text. For simple cases, the util::replaceStrs procedure is likely to be faster.
Details |
Constructor |
Construct a StringReplacer based on the string mappings found in mapTable.
Methods: |
a copy of s with substrings replaced |
Perform substring replacement on the string s
Fields: |