Skip to main content
Solved

Trim remove more than required

  • March 13, 2024
  • 5 replies
  • 66 views

nurbek
Contributor
Forum|alt.badge.img+3

Hi There,

i have workspace and trim transformer - Post/processe/Radarsat2/20240313 for example, it should leave 20240313 name of the file, but it remove 2 at the begining, 0240313 remains as file name. How to keep that “2” at the beginning?

 

Best answer by nielsgerrits

There’s also an transformer LastSectionOfStringRemover on Hub that might help you here:

https://hub.safe.com/publishers/safe-lab/transformers/lastsectionofstringremover

(split on / and keep last part)

Also the FilenamePartExtractor should work in this case.

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

nielsgerrits
VIP
Forum|alt.badge.img+62

When I do this I use an AttributeSplitter and a ListIndexer.


becchr
Influencer
Forum|alt.badge.img+32
  • Influencer
  • March 13, 2024

There’s also an transformer LastSectionOfStringRemover on Hub that might help you here:

https://hub.safe.com/publishers/safe-lab/transformers/lastsectionofstringremover

(split on / and keep last part)


nielsgerrits
VIP
Forum|alt.badge.img+62
  • Best Answer
  • March 13, 2024

There’s also an transformer LastSectionOfStringRemover on Hub that might help you here:

https://hub.safe.com/publishers/safe-lab/transformers/lastsectionofstringremover

(split on / and keep last part)

Also the FilenamePartExtractor should work in this case.


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • March 13, 2024

Or use a StringSearcher with regular expression \d*$

This will find all digits from the end of the string (or you can use \d{8}$ for exactly the last 8 digits).

 


nurbek
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 19, 2024

There’s also an transformer LastSectionOfStringRemover on Hub that might help you here:

https://hub.safe.com/publishers/safe-lab/transformers/lastsectionofstringremover

(split on / and keep last part)

Also the FilenamePartExtractor should work in this case.

Did not know about this transformer, was useful in my case