How to use the SUBSTITUTE operation for Computed Attributes
The SUBSTITUTE operation replaces existing text in a string with a new text. This is case sensitive.
SUBSTITUTE(“HELLO WORLD”, “HELLO”, “BYE”)
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
Example in Formula Editor
Creating a Handle for Shopify