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

MID Function

The MID function returns a string of characters from a text value by counting to the right the number of characters you specify, starting at the position you specify. The MID function compliments the FIRST and LAST functions.

You can use this function in situations where you want to extract parts of a text value that uses a known format, such as a Social Security or telephone number.

Function name MID
Usage model  MID ( in:TEXT, start at:NUM, count:NUM )
Parameters This function requires you to replace three parameters:

in: TEXT

The function returns a string of characters from this text value.

start at: NUM

Specifies the starting position (from the left) to count from (to the right) in the text value.

count: NUM

Specifies the number of characters in the string for the function to return.
Result The string of text the function returns.


A template may require that the Text variable, TelephoneNumber (with the "(999) 999-9999" telephone number pattern), be split into three parts—the area code, the prefix, and the number. The following three expressions could be written in separate computations to get each part of the telephone number.

First, the MID function tells HotDocs to find the area code by returning three characters, starting with the second character (this takes into consideration the opening parenthesis):

MID( TelephoneNumber, 2, 3 )

Second, the MID function tells HotDocs to start at the seventh character (again, taking into account the parentheses and space characters between the area code and the prefix), and return the next three characters:

MID( TelephoneNumber, 7, 3 )

The third expression uses the LAST function to return the last four characters in the text value.

LAST( TelephoneNumber, 4 )