Skip to main content
Solved

How to trim string length to max. 35 characters?

  • February 19, 2018
  • 5 replies
  • 280 views

Forum|alt.badge.img

Hi all,

I'm looking to trim a string to max. 35 characters.

 

Actually 34 characters and ending with a "." to indicate the string has been shortened.

 

What transformer can I use? Or does this require some RegEx?

Thanks,

Ed

Best answer by david_r

You could create a small custom transformer which could contain a StringLengthCalculator, a Tester (_length > 34), which, if true, would use a SubstringExtractor to get the first 34 characters and then add the point.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

david_r
Celebrity
  • 8394 replies
  • Best Answer
  • February 19, 2018

You could create a small custom transformer which could contain a StringLengthCalculator, a Tester (_length > 34), which, if true, would use a SubstringExtractor to get the first 34 characters and then add the point.


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3703 replies
  • February 19, 2018

I would expect the StringFormatter to be able to handle the trimming, but it doesn't seem to want to do that.


Forum|alt.badge.img
  • Author
  • 60 replies
  • February 19, 2018

You could create a small custom transformer which could contain a StringLengthCalculator, a Tester (_length > 34), which, if true, would use a SubstringExtractor to get the first 34 characters and then add the point.

I'm almost there but how to I add the "." at the end of the string?

 

 


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3703 replies
  • February 19, 2018
I'm almost there but how to I add the "." at the end of the string?

 

 

AttributeManager, set the value of that attribute to the original plus a .

 


Forum|alt.badge.img
  • Author
  • 60 replies
  • February 19, 2018
AttributeManager, set the value of that attribute to the original plus a .

 

Thanks!

 

That's what I like about this forum - you guys are so quick to respond!

 

 

Best,

 

Ed