HotDocs Author WorkflowCreate a template Add placeholders Group variables in dialogs Upload a template Create a script

REPLACE Function

The REPLACE function finds a text string you specify in a text value and replaces it with a new text string you specify.

You can use this function to construct a new text value based on another text value, with certain characters replaced with other characters.

The original text value (or answer) is not modified; the REPLACE function simply returns a new text value with the specified characters replaced.

Function name REPLACE
Usage model REPLACE ( in:TEXT, search for:TEXT, replace with:TEXT, replace count:NUM )
Parameters This function requires you to replace four parameters:

in: TEXT

The function searches for text strings within this text value.

search for: TEXT

The function searches this text within the initial text value.

replace with: TEXT

The function uses this value to replace your search results.

replace count: NUM

The function uses this value to determine the number of times the character will be replaced.
Result A text value.

Example

Assume 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 expression uses the REPLACE function to remove all line breaks ( \l ) from the Multi-Line Address Text variable's answer, replaces them with a comma and space, and then returns the result:

REPLACE ( Multi-Line Address, "\l", ", " )

For example, if the Text variable's answer is this:

8039 Beach Blvd
Buena Park, CA 90620
USA

The result of the expression would be a single line, as follows:

8039 Beach Blvd, Buena Park, CA 90620