How to truncate to full words, rather than characters?

Ok so when using the truncate on a word string (e.g. ‘:truncated to 50’), the truncation will of course just stop at whichever letter happens to be character 50.

It’s an issue for me, as I need to maintain the full word for the last word in the string - I’m looking for a solution that behaves more like ‘:truncate to word 50’.

Felt like this would have been a common issue for people but can’t seem to find anything on it - any ideas, or RegEx expressions?

Any help would be super appreciated!

You could use :split by and then get the first or last item as a text. :slight_smile:

Edit: You can use #item to then pull any word(s) in the list that was created by split by.

Hi there, @josh27… I will throw this “idea” out there, if only so folks can ridicule me for suggesting such a hack.

split

The split by character is a space, and the find and replace finds a comma and replaces it with a space.

Anyway, it’s something, and I hope it helps, even if it serves as an example of what you definitely do not want to do.

Best…
Mike

Edit: it looks like @philipp.laengle107 beat me to the :split by suggestion by a minute or two, so now folks can ridicule him first. :wink:

4 Likes

Thank you both for jumping in here - :split-by did the trick!

:open_hands: :open_hands:

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.