Expression language
Text functions
Reference for the Text Functions category - join, split, format, search, clean up, match patterns and encode text.
The Text Functions category builds and cleans up text: case subjects, email bodies, reference numbers, API values. Unless a function says otherwise, non-text values you put into a text slot are converted to text, and an empty value gives empty text.
Three functions that also appear in this category, Option Label, Organization URL and Record Link, are described with Choices and records. To String is described here; the reverse conversions are on Conversion.
Build text
Section titled “Build text”Concatenate
Section titled “Concatenate”Concatenate(value1, value2, …)Joins two or more values into one text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Values | Any | Yes, at least two | The values to join, in order. Non-text values are converted to text. |
- Empty values add nothing. You never see the word “null” in the result.
- Add separators such as spaces or commas as Text constants between the values.
Examples
Concatenate(firstname, " ", lastname)gives “Nancy Davolio”.Concatenate("CASE-", ticketnumber)builds a reference for an email subject.
Format
Section titled “Format”Format(template, value1, …)Fills a template with values. Use it when the text has a fixed shape with several values in the middle.
| Parameter | Type | Required | Description |
|---|---|---|---|
| String To Format | Text | Yes | The template. {0} is replaced by the first value, {1} by the second, and so on. |
| Values | Any | Yes | The values for the placeholders, in order. Converted to text. |
- A placeholder that has no matching value, such as
{2}when you give only two values, fails the run. - To show a literal brace, double it:
{{shows{.
Example: Format("Opportunity {0} for {1} closes on {2}", name, Customer.name, estimatedclosedate).
Join(list, separator)Joins the items of a list into one text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| List | List of any type | Yes | The items to join. |
| Separator | Text | No | Placed between items. Without it, items are joined with nothing in between. |
- Items are converted to text as in Concatenate.
- Empty items are skipped, so you never get “Golf, , Sailing”.
- A missing list gives empty text.
Examples
Join(OptionLabel(new_interests), ", ")turns a multi-select choice into “Golf, Sailing”.Join(Split(emailaddresses, ";"), ", ")tidies a semicolon-separated list of addresses.
Pad Left / Pad Right
Section titled “Pad Left / Pad Right”PadLeft(text, totalLength, padCharacter)PadRight(text, totalLength, padCharacter)Adds characters to the start (Pad Left) or end (Pad Right) of a text until it reaches a length.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to pad. A number is converted to text. |
| Total length | Whole Number | Yes | The length you want. |
| Pad character | Text | No | The character to add. Defaults to a space. Only the first character is used. |
- Text that is already long enough is returned unchanged. It is never cut.
Example: PadLeft(SequenceNumber, 6, "0") turns 42 into “000042” for an invoice number.
Measure and search
Section titled “Measure and search”String Length
Section titled “String Length”Length(text)Returns the number of characters in a text. Shown as Length in the outline.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to measure. |
- Empty text gives
0.
Example: Length(telephone1) < 8 flags phone numbers that are too short.
Index Of
Section titled “Index Of”Index Of(text, search)Returns the position of the first occurrence of a text inside another text. Shown as Position Of in the outline.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to search in. |
| Search | Text | Yes | The text to find. |
- Positions start at
0. The result is-1when the text is not found. - The search is case-sensitive: “Contoso” does not find “contoso”.
- When the text or the search is empty, the result is
-1.
Example: Index Of(emailaddress1, "@") gives the position of the @ sign.
Last Index Of
Section titled “Last Index Of”Last Index Of(text, search)Returns the position of the last occurrence. Shown as Last Position Of in the outline. Same parameters and rules as Index Of.
Example: Last Index Of(fullname, " ") finds the space before the last name.
Match Pattern
Section titled “Match Pattern”ValidateText(text, pattern)Checks whether a text matches a regular expression. Use it in validations for formats such as postal codes, tax IDs or reference numbers.
| Parameter | Type | Required | Description |
|---|---|---|---|
| String Argument | Text | Yes | The text to check. Empty text is checked as "". |
| Pattern | Text | Yes | A regular expression. |
- Matching ignores case. To make the pattern case-sensitive, start it with
(?-i). - An empty pattern always matches.
- A typed pattern that is not valid is reported in the editor, before the logic runs.
- A pattern that takes too long to evaluate fails the run. Keep patterns simple and anchored with
^and$.
Example: ValidateText(emailaddress1, "^[^@\s]+@[^@\s]+\.[a-z]{2,}$") checks that an email address looks valid.
Cut and clean
Section titled “Cut and clean”Substring
Section titled “Substring”Substring(text, start, length)Returns part of a text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| String Argument | Text | Yes | The text to cut. |
| Index Argument | Whole Number | Yes | Where to start. 0 is the first character. |
| Length (optional) | Whole Number | No | How many characters to return. Without it, the rest of the text is returned. |
- Positions outside the text never fail: a start beyond the end gives empty text, a negative start counts as 0, and a length past the end is cut short.
- Empty text gives empty text.
Examples
Substring(ticketnumber, 4)turns “CAS-01234” into “01234”.Substring(emailaddress1, Index Of(emailaddress1, "@") + 1)gives the email domain, such as “contoso.com”.
Left / Right
Section titled “Left / Right”Left(text, count)Right(text, count)Returns the first (Left) or last (Right) characters of a text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text. |
| Number of characters | Whole Number | Yes | How many characters to return. |
- A count of 0 or less gives empty text. A count longer than the text gives the whole text.
Examples
Right(accountnumber, 4)shows only the last four digits.Left(StripHtml(description), 200)keeps a subject or summary within 200 characters.
Trim(text)Removes spaces at the start and end of a text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to trim. |
Example: Null Or Empty String(Trim(new_comment)) treats a comment of only spaces as empty.
To Upper Case / To Lower Case
Section titled “To Upper Case / To Lower Case”Uppercase(text)Lowercase(text)Converts text to capitals or small letters, using language-neutral rules. Shown as Uppercase and Lowercase in the outline.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to convert. |
Example: Uppercase(address1_country) gives “JORDAN”.
Replace
Section titled “Replace”Replace(text, old, new)Replaces every occurrence of one text with another.
| Parameter | Type | Required | Description |
|---|---|---|---|
| String Argument | Text | Yes | The text to change. |
| Old Argument | Text | Yes | The text to find. Matching is case-sensitive. |
| New Argument | Text | Yes | The replacement. |
Example: Replace(description, "Contoso Ltd", "Contoso Group") updates a company name after a rebrand.
Remove HTML
Section titled “Remove HTML”StripHtml(text)Turns rich text, such as an email body or a rich-text note, into readable plain text.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The HTML or rich text. |
- Line breaks are kept for line breaks, paragraphs, list items, table rows and headings.
- Script and style content is removed, entities such as
&are decoded, and repeated spaces and blank lines are collapsed.
Example: Left(StripHtml(Email.description), 2000) stores the text of an incoming email in a case description.
Patterns
Section titled “Patterns”The three pattern functions use regular expressions, like Match Pattern. They share these rules:
- Matching ignores case by default. Start the pattern with
(?-i)to make it case-sensitive. - A typed pattern that is not valid is reported in the editor before the logic runs.
- A pattern that takes too long to evaluate fails the run.
Extract with Pattern
Section titled “Extract with Pattern”RegexExtract(text, pattern, group)Returns the first part of a text that matches a pattern.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to search. |
| Pattern (regular expression) | Text | Yes | What to find. |
| Group (optional) | Whole Number | No | Which part of the match to return. 0 or empty returns the whole match; 1 returns the first group in parentheses. |
- No match, empty text or an empty pattern gives empty text.
Example: RegexExtract(description, "PO-(\d+)", 1) takes the purchase order number out of an email body: “Please ship PO-48812 today” gives “48812”.
Extract All with Pattern
Section titled “Extract All with Pattern”RegexExtractAll(text, pattern, group)Returns every part of a text that matches a pattern. Same parameters as Extract with Pattern.
- No match, empty text or an empty pattern gives an empty list.
Example: RegexExtractAll(description, "CAS-\d{5}-\w{6}") lists every case number mentioned in an email.
Replace with Pattern
Section titled “Replace with Pattern”RegexReplace(text, pattern, replacement)Replaces every part of a text that matches a pattern.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to change. |
| Pattern (regular expression) | Text | Yes | What to replace. |
| Replacement | Text | Yes | The new text. Refer to groups with $1, $2, or ${name} for named groups. |
- An empty pattern returns the text unchanged. Empty text gives empty text.
Examples
RegexReplace(telephone1, "[^0-9+]", "")keeps only digits and the plus sign: “+962 (6) 555-0100” becomes “+96265550100”.RegexReplace(fullname, "^(\w+) (\w+)$", "$2, $1")turns “Nancy Davolio” into “Davolio, Nancy”.
Split text into a list
Section titled “Split text into a list”Split(text, separator)Splits a text into a list at each separator.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to split. |
| Separator | Text | Yes | Where to split, for example ";". |
| Trim entries and remove empty ones | Yes/No | No | Defaults to Yes. |
- With Trim entries and remove empty ones on, each entry is trimmed and empty entries are dropped: “a; b;;” gives
a,b. Turn it off to keep entries exactly as written. - An empty separator gives the whole text as one item.
- Empty text gives an empty list.
Example: Split(new_ccemails, ";") turns “anne@contoso.com; raj@contoso.com” into a list of two addresses you can loop over in a flow.
Format values as text
Section titled “Format values as text”To String
Section titled “To String”toString(value, format)Formats a date, number or ID as text. Shown as To Text in the outline.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Value | Date and Time, any number, Unique Identifier or Lookup | Yes | The value to format. |
| Format | Picked from a list | No | How to format it. The list depends on the value’s type. |
Formats you can pick:
| For | Formats |
|---|---|
| Date and Time | Short (d), Long (D), Full Short (f), Full Long (F), General Short (g), General Long (G), Month Day (M), Short Time (t), Long Time (T), ISO Full DateTime (yyyy-MM-ddTHH:mm:ss), European DateTime Style (dd/MM/yyyy HH:mm), US DateTime Style (MM/dd/yyyy hh:mm tt), ISO Date (yyyy-MM-dd), European Date (dd/MM/yyyy), Long Format Date (MMM dd, yyyy) |
| Numbers | Percent (P), Exponential (E2), Currency (C), Two Decimals (F2) |
| Unique Identifier | Hyphens Separated, Non Separated, Braces, Parentheses, Hex |
- Dates are formatted as stored. A User Local date is in UTC, so convert it with Convert From Utc first when you want the user’s local time.
- For a lookup with a format, the record’s ID is formatted.
- An empty value gives empty text.
- Formatting follows the server’s regional settings, not the user’s: named formats (Short, Long, Currency, Percent and so on), month names and the decimal separator can differ between environments. For text that other systems read, use explicit patterns such as
yyyy-MM-ddorF2.
Examples
toString(estimatedclosedate, "yyyy-MM-dd")gives “2026-11-30”.toString(closeprobability, "P")shows a probability as a percentage.
Encode and decode
Section titled “Encode and decode”These functions prepare text for web addresses, HTML and integrations, for example when a logic flow calls an external service through a service connection.
Base64 Encode / Base64 Decode
Section titled “Base64 Encode / Base64 Decode”Base64Encode(text)Base64Decode(text)Converts text to and from Base64, using UTF-8.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to encode or decode. |
- Base64 Decode also accepts the URL-safe alphabet (
-and_) and missing=padding. - Text that is not valid Base64 decodes to empty text; the run does not fail.
- Empty text gives empty text.
Example: Concatenate("Basic ", Base64Encode(Concatenate(ApiUser, ":", ApiKey))) builds a basic authorization header.
URL Encode / URL Decode
Section titled “URL Encode / URL Decode”UrlEncode(text)UrlDecode(text)Escapes text for use in a web address, or reverses it.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to encode or decode. |
- URL Encode escapes text for a URL path or query value: a space becomes
%20. - URL Decode reads both
%20and+as a space and leaves escapes that are not valid as written.
Example: Concatenate("https://maps.example.com/?q=", UrlEncode(address1_composite)) builds a map link for an account’s address.
HTML Encode / HTML Decode
Section titled “HTML Encode / HTML Decode”HtmlEncode(text)HtmlDecode(text)Makes text safe to show inside HTML, or turns HTML entities back into characters.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Text | Text | Yes | The text to encode or decode. |
- HTML Encode turns special characters into entities, so
<becomes<and the text displays as written. - HTML Decode turns entities such as
&back into characters.
Example: Concatenate("<p>Dear ", HtmlEncode(Customer.name), ",</p>") in an email body keeps a name like “Smith & Sons” from breaking the HTML.
Related
Section titled “Related”- Choices and records: Option Label, Organization URL, Record Link
- Conversion
- Empty values