Remove Extra Spaces From an Answer
When a user answers a Text variable in the interview, unless the variable has a pattern attached to it, the user can type almost anything in the box. As the template developer, you may want to alter the user's answer to be more consistent with the rest of the document. One common change you may want to make is to remove extra spaces between sentences. For example, if you use only one space between sentences in the template, but a user enters two spaces between sentences in an answer, you can write a computation to remove the duplicate spaces.
The first example uses a WHILE loop to repeatedly examine the answer of a Text variable to see if it contains any duplicate spaces. If two spaces are found, the answer is modified to remove the second space. The process is repeated until all duplicate spaces are removed.
The second example uses the STRIP expression model to remove any leading or trailing spaces from an answer.