---
title: "Transforming string data"
description: "Create templates that modify and format text data, in your documents."
canonical_url: "https://resources.docmosis.com/template-tutorials/expressions-strings"
last_reviewed: 2026-06-08
---
# Transforming string data
Depending on the particular software application you are using, it might not be possible to change your data before sending it to Docmosis.
Docmosis has a range of string functions you can use within the templates to modify and format your data and achieve the desired result in your generated documents.
## Examples
To understand the functions in this example, you may find it helpful to download the supplied *ExpressionsStrings.zip* and view the example template together with the output file.
## Working with strings
Fixed or static strings in your templates should be formed using single quotes.
For example: \<\\> This person is a Male. \<\\>
In the above example, 'male', is a fixed string that is being used for comparison in the \<\\>
will achieve this:
| Input Data | Desired Output |
| --- | --- |
| f | Female |
| F | Female |
| m | Male |
| M | Male |
| (all other letters) | Other |
For the full list of logic and transform functions, refer to the "Logic and Transform Functions" section in the Template Guide.
## Using list data in a sentence
The example template shows how to loop through a list of values and use them in a comma\-separated sentence like the one shown below.
Input Data:
"apples", "bananas", "oranges"
Desired sentence in finished document:
"My favorite fruits are apples, bananas and oranges."
The challenge is to insert a comma between values, except for the last two, and to insert the word "and" between the last two values.
To achieve this result in Docmosis, use an \<\\>
What is the value of $myVar : \<\<$myVar\>\>
Single quotes should also be used for fixed or static strings used in expressions, for example in conditional sections.
Animal \= \<\\>
\<\\>
The Animal is VERY BIG.
\<\\>
The Animal is not an Elephant.
\<\\>
**Simple String Functions**
The functions can be called with one or more parameters. The input parameters can be from your data. The output of the function will appear in the finished document.
City \= \<\\>
The city above has \<\<{**length**(city)}\>\> characters.
A name in lower case : \<\<{**toLowerCase**(‘Bob Mathews’)}\>\>
A name in UPPER case : \<\<{**toUpperCase**(‘Bob Mathews’)}\>\>
A name in Title case : \<\<{**titleCase**(‘bob mathews’)}\>\>
The result of one function can be passed to another function.
Did you know that “\<\<{**titleCase**(city)}\>\>” has \<\<{**round**(**length**(city))} \>\> characters in it’s name.
**Advanced String Functions**
You can use a **Map** function to choose a String to display based on a field in your data.
For example your data may contain ‘M’ or ‘F’ and you want to display ‘Male’ or ‘Female’:
Gender \= \<\\>
Gender is \<\<{**map**(gender, ‘M’, ’Male’, ‘F’, ‘Female’, ‘Other’)}\>\>
What if the data contains upper or lower case letters : ‘m’ , ‘M’ , ‘f’ or ‘F’?
Gender \= \<\\>
Gender is \<\<{**map**(**toUpperCase**(genderTwo), ‘M’, ’Male’, ‘F’, ‘Female’, ‘Other’)} \>\>
What cities start with ‘New’ or end with ‘City’
\<\\>
\<\\>
\<\\> starts with ‘New’
\<\\>
\<\\>
\<\\> ends with ‘City’
\<\\>
\<\\>
**Comma Separated Data used in a Sentence**
Display a list of data in a comma separated sentence:
My favorite fruits are \<\\>\<\\>\<\2\)\&\&($itemnum\<$size\-1\)}\>\>, \<\\>\<\\> and \<\\>\<\\>.
*This example is using:*
- *a Repeating Section “\<\