MID( TEXT, NUM, NUM )

Placeholder Tooltip Replace With
TEXT in: Text A text value, such as a Text variable, from which the specified number of characters will be returned. This can be a fixed text value, inside quotation marks.
NUM start at: Number A number value, such as a Number variable or a number you type. This number specifies where HotDocs starts "returning" characters.
NUM count: Number A number value, such as a Number variable or a number you type. It specifies the number of characters you want returned.

Returns a Text value

Like the FIRST and LAST expressions, this expression extracts a specified number of characters from within a text string.

For example, a form template may require that the text variable, Telephone Number (with the telephone number pattern), be split into three pre-formatted fields—the area code, the prefix, and the number. In the following example, three different computations would be scripted and inserted into the different fields as follows:

MID( Telephone Number, 2, 3 )

MID( Telephone Number, 7, 3 )

LAST( Telephone Number, 4 )

The first computation, which you would place in the area code field, tells HotDocs to include three characters, starting with the second character (this takes into consideration the opening parenthesis.)

The second computation (the prefix field) starts at the seventh character (again, taking into account the parentheses and space characters between the area code and the prefix), and inserts the next three characters.

The third expression, which uses the LAST expression, returns the last four digits of the phone number by counting backwards from the last character.