Solutons Lounge

How to omit the last 5 characters in any text? – Need help


Hi all,

For the life of me I cannot figure out how to do this. I want basically chop off the last 5 characters in a given piece of text, the text is always going to be longer than 5 characters but will vary in length e.g 10-15 characters.

I’ve tried:

  • Truncate, but that doesn’t work because of the text length variable
  • I’ve tried using regex (.{3}) but that only captures the last 3 characters. Any way I can invert what it captures?

Anyone have suggestions? Thanks a bunch!

Text:truncated to (Text:number of characters – 5) is a non-regex method that would work

You could use the same regex (.{5}) inside :find and replace. Replace with nothing to remove them. That’s probably the cleanest solution.



1 Like

you can use split by to remove the characters for split by {goat} will remove characters starting from goat

Didn’t know you could do that on truncate, this did the trick! Thanks!!

Who mentioned anything about a goat?

But in any case, how is that applicable here?

Unless you mean, first establish what the last 5 characters are (by truncating from end to 5), then split the main text by those characters, and select the first item? That would work.

You could do the same with find and replace: truncate the string to 5 chars form the end, then use find and replace to replace those character in the original string with nothing.

Both would work, but Text:truncated to (Text:number of characters - 5) is simpler (I think so anyway).



Source link

Exit mobile version