Using text operations

How to use text operations in Plytix formulas, with real examples of when you'd use each one

Text operations let you transform, clean, search, extract from, and restructure text values, from simple case changes to stripping HTML and building custom identifiers. This article covers all seventeen text operations, organized by what they do, plus common use cases combining them.

Case Transformation

UPPER

Converts a whole text string to UPPERCASE.

Syntax:

UPPER(text)
  • text: the string to convert.

Example:

UPPER("Hello World")

Result: HELLO WORLD

LOWER

Converts a whole text string to lowercase.

Syntax:

LOWER(text)
  • text: the string to convert.

Example:

LOWER("HELLO World")

Result: hello world

PROPER

Capitalizes the first letter of every word in a text.

Syntax:

PROPER(text)
  • text: the text to capitalize. Only the first letter of each word is capitalized.

Example:

PROPER("hello world")

Result: Hello World

Cleaning & Formatting

TRIM

Removes extra spaces from a text, leaving only a single space between words.

Syntax:

TRIM(text)
  • text: the string to trim.

Example:

TRIM(" Hello World ")

Result: Hello World

ESCAPEHTML

Removes all HTML tags from a text.

Syntax:

ESCAPEHTML(text)
  • text: the text to remove HTML tags from.

Example:

ESCAPEHTML("<script>alert('Hello')</script><b>Hello World</b>")

Result: Hello World

Formula in use: stripping HTML while keeping line breaks

To remove HTML from a rich text field while keeping each list item on its own line, rather than running everything together:

Turning <ul><li>This</li><li>That</li><li>The other<br></li></ul> into:

This
That
The other
ESCAPEHTML(SUBSTITUTE($ATT.RICH_TEXT, "<li>", ""))

Formula in use: stripping HTML while keeping bullet points

To keep a visible bullet symbol in the plain-text version, add it into the replacement:

ESCAPEHTML(SUBSTITUTE($ATT.RICH_TEXT, "<li>", "- "))

You can copy and paste either formula into your own account, just replace $ATT.RICH_TEXT with your own attribute.

ESCAPESTYLE

Removes all styling elements from a text, while keeping the HTML tags themselves.

Syntax:

ESCAPESTYLE(text)
  • text: the text to remove styling elements from.

Example:

ESCAPESTYLE("<script>alert('Hello')</script><b style=\"color: red\">Hello World</b>")

Result: <script>alert('Hello')</script><b>Hello World</b>

Unlike ESCAPEHTML, which strips tags entirely, ESCAPESTYLE keeps the tags themselves and only removes inline styling (like style="color: red").

Extracting Substrings

LEFT

Extracts a substring starting from the leftmost character.

Syntax:

LEFT(text_attribute, num_chars)
  • text_attribute: the text to extract characters from.
  • num_chars (optional, 1 by default): the number of characters to extract from the left.

Example:

$ATT.LABEL = "Pineapple"

LEFT($ATT.LABEL, 4)

Result: Pine

Extracts a substring starting from the rightmost character.

Syntax:

RIGHT(text_attribute, num_chars)
  • text_attribute: the text to extract characters from.
  • num_chars (optional, 1 by default): the number of characters to extract from the right.

Example:

$ATT.LABEL = "Pineapple"

RIGHT($ATT.LABEL, 5)

Result: apple

MID

Extracts a given number of characters from the middle of a string.

Syntax:

MID(attribute, start_char, num_chars)
  • attribute: the text to extract characters from.
  • start_char: the position of the first character to extract.
  • num_chars: the number of characters to extract.

Example:

$ATT.LABEL = "Pineapple"

MID($ATT.LABEL, 3, 4)

Result: neap

LEN

Counts the number of characters in a string.

Syntax:

LEN(text)
  • text: the string to measure.

Example:

LEN("Hello World")

Result: 11

Finding Text

FIND

Finds the first position of a string within a text. Case sensitive.

Syntax:

FIND(search_for, text_to_search,[starting_at])
  • search_for: the string to look for.
  • text_to_search: the text to search within.
  • starting_at (optional, 1 by default): the character position to start searching from.

Example:

FIND("e", "Hello There!")

Result: 2

If no match is found, the result is NULL.

Finds the first position of a string within a text. Not case sensitive.

Syntax:

SEARCH(search_for, text_to_search, [starting_at])
  • search_for: the string to look for.
  • text_to_search: the text to search within.
  • starting_at (optional, 1 by default): the character position to start searching from.

Example:

SEARCH("lo", "HELLO WORLD")

Result: 4

Formula in use: searching and returning values based on keywords

Search a description for specific words or phrases, and return a corresponding value based on what’s found, for example, detecting a product type from its description:

IF(GT(SEARCH("boot", $ATT.TEXT), 0), "Snowboard boots", IF(GT(SEARCH("jacket", $ATT.TEXT), 0), "Snowboard jacket", "Unknown"))

This checks whether the description contains “boot,” then “jacket,” returning the matching product type, or “Unknown” if neither is found.

Replacing Text

REPLACE

Replaces part of a string with a different string, based on position.

Syntax:

REPLACE(text, position, length, new_text)
  • text: the text to modify.
  • position: where the replacement begins (starting from 1).
  • length: how many characters to replace.
  • new_text: the text to insert.

Example:

REPLACE("Pineapple", 5, 5, "nuts")

Result: Pinenuts

SUBSTITUTE

Replaces existing text with new text, based on matching content rather than position.

This operation is case sensitive.

Syntax:

SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])
  • text_to_search: the text to search and replace within.
  • search_for: the string to search for. This matches partial words too, so searching for “pop” also matches within “popular.”
  • replace_with: the replacement string.
  • occurrence_number (optional): replaces only that specific occurrence. If omitted, every occurrence is replaced. If the number given exceeds how many occurrences actually exist, the original string is returned unchanged.

Example:

SUBSTITUTE("HELLO WORLD", "HELLO", "BYE")

Result: BYE WORLD

Formula in use: creating a URL handle for Shopify

LOWER(SUBSTITUTE($ATT.LABEL, " ", "-"))

This converts a product’s label into a lowercase, hyphenated handle, for example, turning “Everyday Vest” into “everyday-vest,” a common requirement for platform URL slugs.

RSUBSTITUTE

Replaces only the last occurrence of a string in a text.

Syntax:

RSUBSTITUTE(text_to_search, search_for, replace_with)
  • text_to_search: the text to search and replace within.
  • search_for: the string to search for. This matches partial words too, so searching for “pop” also matches within “popular.”
  • replace_with: the replacement string.

Example:

RSUBSTITUTE("HELLO WORLD", "O", "X")

Result: HELLO WXRLD

List Operations

JOIN

Concatenates values together with a delimiter between each one.

Syntax:

JOIN([values], delimiter)
  • values: the values to join, enclosed in square brackets.
  • delimiter: the character or string placed between each value.

Example:

JOIN(["a", "b"], "-")

Result: a-b

 The delimiter can be left blank, e.g. JOIN(["1", "2", "3"], ) results in 1 2 3.

FILTER

Returns a list of items that meet a specified condition.

Syntax:

FILTER(condition, range)
  • condition: a formula evaluating to true or false for each item.
  • range: the data to filter.

Example:

FILTER(GT($$ITEM, 2), [1, 2, 3, 4])

Result: [3, 4]

Common Use Cases for Text Operations

Building a URL-friendly handle

As shown in SUBSTITUTE’s example above, combining LOWER and SUBSTITUTE turns a readable product name into a lowercase, hyphenated handle, useful for Shopify or any platform requiring URL-safe slugs.

Converting rich text into clean plain text for a feed

Combine ESCAPEHTML and SUBSTITUTE (as shown in ESCAPEHTML’s examples above) to strip HTML formatting from a description while preserving readable line breaks or bullet points, useful for marketplaces that don’t accept rich text.

Detecting a product type or category from free text

As shown in SEARCH’s example above, combine SEARCH with nested IF statements to classify a product based on keywords found in its description, without manually tagging every product.

Extracting a product code from a compound SKU

If your SKUs follow a consistent pattern (like a 3-character brand prefix followed by a product number), use LEFT, RIGHT, or MID to pull out just the part you need for a specific Channel:

RIGHT($ATT.SKU, LEN($ATT.SKU) - 4)

This strips a 4-character prefix off the front of a SKU, returning everything after it.

Standardizing capitalization from multiple suppliers

Use PROPER (or UPPER/LOWER depending on the requirement) to clean up inconsistent capitalization when product data comes from suppliers with different formatting habits.

Turning a Multiselect attribute into a clean, delimited string

Use JOIN to combine a Multiselect attribute’s values into one string with your choice of separator, avoiding the brackets CONCAT would otherwise add. See Operators for more on CONCAT.

Filtering a list down to only the values you need

Use FILTER to narrow down a list to only the items meeting a specific condition, for example, filtering a list of sizes down to only those in stock, before passing the result to JOIN for display.

Frequently Asked Questions

  • ESCAPEHTML strips all HTML tags from your text, leaving only plain text.
  • ESCAPESTYLE preserves the HTML structure and tags while removing any inline styling attributes (such as style="...").

FIND is case-sensitive, whereas SEARCH is case-insensitive. Aside from case sensitivity, both functions behave identically.

  • SUBSTITUTE replaces every matching occurrence in a text string (or a single specific instance if you provide an occurrence number).
  • RSUBSTITUTE only ever replaces the last matching occurrence.

Yes. SUBSTITUTE (as well as RSUBSTITUTE) is case-sensitive.