HotDocs Models: replace( text, text, text, num )

Placeholder Replace With
text The name of a Text variable or the string of characters you need to search
text The text for which you are searching, which may include the following special characters:
\\ -- backslash character
\h -- non-breaking hyphen
\l -- line break
\p -- paragraph mark
\s -- non-breaking space
\t -- tab
text The text you want to use as a replacement, which may include the following special characters:
\\ -- backslash character
\h -- non-breaking hyphen
\l -- line break
\p -- paragraph mark
\s -- non-breaking space
\t -- tab
num Controls the number of times the character is replaced  
(optional) For example, if no number is specified, all found instances will be replaced; however, if you include a 1 as a parameter, only the first found instance will be replaced.

This expression lets you search a string of text for a given character string and replace the results with new text.

For example, perhaps you want to take the information in an address block (which will most likely appear as separate lines) and display it as a single line, with each "part" separated by a comma. The following script removes all line breaks ( \l ) from the Text variable, MultiLineAddress, replaces them with a comma and space, and then sets that result to the Text variable SingleLineAddress:

set SingleLineAddress to replace(MultiLineAddress, "\l", ", ")