TEXT CONTAINS TEXT

Placeholder Replace With
TEXT A text value, such as a Text variable
TEXT A text value, such as a Text variable. Any text you type must be in quotation marks.

Returns a True/False value

The TEXT CONTAINS TEXT expression determines whether the first text value contains the same text as the second value. If it does, it returns the value of true.

In this example, some states in the United States are officially recognized as “commonwealth” states. In the following script, HotDocs examines the answer the user provides for the variable State Name to see if the user has listed one of these states. If so, HotDocs attaches the correct designation to the merged answer:

IF "massachusetts virginia kentucky pennsylvania" CONTAINS State Name

"The Commonwealth of «State Name»"

ELSE

"The State of «State Name»"

END IF

At first glance, this computation may seem backward. You may think you would test State Name to see if it contains any of the commonwealths listed in the text string (for example, IF State Name CONTAINS "massachusetts virginia kentucky pennsylvania"). However, if you used that method, the answer the user assigns to State Name TE would have to contain everything between the quotation marks—"massachusetts virginia kentucky pennsylvania"—and you would never produce a true statement. Of course, you could test State Name against each individual commonwealth (for example, IF State Name CONTAINS "massachusetts" OR IF State Name CONTAINS "virginia" and so forth), but by "switching" the values for the placeholders and placing all of the commonwealths in one text string, you eliminate a lot of repetitive typing.

 

Also see TEXT STARTS WITH TEXT and TEXT ENDS WITH TEXT for similar functions.