Truncating Product Titles to Fit Within 80 Characters Using make.com

How can I truncate product titles to fit within 80 characters, ensuring each title ends with a complete word? I have a list of product titles, each exceeding 100 characters and consisting of multiple words. I want to shorten them while maintaining readability by ending each truncated title with a complete word. Can someone provide a solution using make.com?

@samliew already made a suggestion, but how exactly can you solve this with a function?

I’m managing a project where I need to process numerous product titles. These titles often exceed 100 characters and need to be truncated to fit within a maximum length of 80 characters. However, merely cutting off the title at 80 characters might result in incomplete words at the end, making the titles less readable. I’m looking for a solution using make.com that splits each title into words, removes words until the length is under 80 characters, and then adds ellipsis (…) to indicate truncation, ensuring that each truncated title ends with a complete word.

Consider the following example titles:

  1. “This is a very long product title that needs to be shortened because it exceeds the maximum length”
  2. “Another long title that cannot fit in its full length and therefore needs to be cut off”

I want to truncate these titles to fit within 80 characters, like this:

  1. “This is a very long product title that needs to be shortened because the…”
  2. “Another long title that cannot fit in its full length and therefore…”

Thanks for your help guys!

Welcome to the Make community!

Screenshot_2024-02-20_151445

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

^(?<text>.{0,77})\b(?=\s|$)

Proof

https://regex101.com/r/EguoY4

Important Info

  • :warning: Global match must be set to NO!

For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!

samliewrequest private consultation

2 Likes

Thanks for your fast response @samliew Can you explain this? Where did you get the information or where could you find out how it works?

No problem, glad I could help!

It’s easy to visualize regex in your mind if you know what you’re doing. You can find more information on regex using the links below:

For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!

1. If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

others can save time when catching up with the latest activity here, and

  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

samliewrequest private consultation

2 Likes

why 0,77 just for understanding?

Because your ellipsis ... is three characters long.

2 Likes