How to use the SUBSTITUTE operation for Computed Attributes
Definition
The SUBSTITUTE operation replaces existing text in a string with a new text.
⚠️ This operation is case sensitive.
Example
SUBSTITUTE(“HELLO WORLD”, “HELLO”, “BYE”)
Result:
BYE WORLD
Syntax Guide
SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])
text_to_search - The text within which to search and replace
search_for - The string to search for within text_to_search
search_for will match parts of words as well as whole words; therefore a search for "pop" will also replace text within "popular"
replace_with - The string that will replace search_for
occurrence_number - [ OPTIONAL ] - occurrence_number - [ OPTIONAL ] - Specifies which occurrence of text_to_search you want to replace with new_text.
- If you specify occurence_number, only that particular instance is replaced.
- Otherwise, every occurrence is replaced with the replace_with text.
- If the occurence_number is greater than the number of occurrences, the original string will be returned with no changes
Formula In Use
Creating a Handle for Shopify
LOWER(SUBSTITUTE($LABEL," ","-"))
What's Next
- Learn more about how to write formulas
- Check out the FIND operation
- Check out the RSUBSTITUTE operation
If you have any questions just click on the chat box in the bottom-right corner and we'll be happy to answer them...
and please let us know 👇