Skip to main content
Solved

Remove the last n delimeters from a string

  • September 12, 2024
  • 2 replies
  • 59 views

james_c_452
Supporter
Forum|alt.badge.img+7

Hi,

I keep going in circles and can’t think of an easy way to do this. Has anyone got any tips
Basically, I have an attribute such as “TEST_240829_MLS_5_316460_5816230”

What I what to do is remove “_316460_5816230” from the end. I’m wanting it to adaptively remove this part of the string from several thousand inputs.

Normally I would use the attribute trimmer however the length of this part of the string will change (not a constant thing I can remove). This part of the input string does always start at the second last occurrence on the “_” delimiter and go until the end. The amount of delimiters is not constant in the part of the string I want to keep though, so I also can’t use the attribute splitter and then rebuild the part I want from the parts of a list

Is there an easy wany to do this?

Best answer by bwn

Can use a RegEx solution to define RegEx Group 1 as being the text in front of the second last “_” and keep just this portion.

^(.+)_.*_.*$

 

Input

 

StringReplacer Output

 

View original
Did this help you find an answer to your question?

2 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • Best Answer
  • September 12, 2024

Can use a RegEx solution to define RegEx Group 1 as being the text in front of the second last “_” and keep just this portion.

^(.+)_.*_.*$

 

Input

 

StringReplacer Output

 


james_c_452
Supporter
Forum|alt.badge.img+7
  • Author
  • Supporter
  • September 12, 2024

I knew there was a way I’d done before. Thanks @bwn !


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings