Returns as many characters as possible, starting from the beginning of a string and counting up to a delimiter, while staying within max_length. If the string is already within max_length, the function returns string exactly as it was passed in.
Always counts in the natural direction of the advertiser’s locale. For example, if the advertiser’s language is English, this function counts from left to right.
REDUCE_WORDS(string, max_length, delimiter, [delimiter], ...)
Specify the function name in upper case:
- string: An inventory string attribute such as
DESCRIPTION, or a static string surrounded by quotes such as "My great shoe store".
Specify standard inventory attributes in upper case; use the Search Ads 360 UI for guidance on specifying custom attributes.
- max_length: the maximum number of characters in the output string. Can be any of the following:
- 0 (zero).
- A positive integer, such as 5.
- An expression or inventory function that returns a positive number.
- delimiter: A single character such as " ", a static string such as "store", or an inventory string attribute such as
BRAND. If you specify more than one delimiter, the function uses the delimiter that yields the longest string fitting within max_length.
REDUCE_WORDS("My great shoe store", 10, " ")returns "My great". To calculate this string, the function follows these steps:
Finds the last instance of the delimiter (which is the space between "shoe" and "store").
Counts backwards 10 characters to see if it has reached the beginning of the string.
In this example, the function doesn't reach the beginning, so it moves to the previous instance of the delimiter, the space between "great" and "shoe", and counts backwards 10 characters.
The function reaches the beginning of the string before finishing the count, so it returns everything preceding the delimiter.
REDUCE_WORDS(DESCRIPTION, 15, " and"). If the inventory feed specifies "Low prices and wide selection" for the
DESCRIPTIONattribute, this function returns "Low prices". Note that the delimiter includes a space before "and". Without the space in the delimiter, the function would return "Low prices ".
REDUCE_WORDS(DESCRIPTION, 15, " "). If the inventory feed specifies "Low prices" for the
DESCRIPTIONattribution, the function returns "Low prices".