Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Need to Trim Suffix Strings of Variable Length

Rob48
8 - Asteroid

I'm working with data that has suffix strings of variable length that I need to remove to get at my core data string.  I know the list of suffixes I need to remove.  My challenges are,  the core strings I need to keep are of varying length, spaces, etc, the suffixes I need to trim are around 100 and of varying length and spacing, and periodically new suffixes will be added to the existing list to trim.  My only solution right now is to run a chain of 100 separate Formula or Multi-Filed tools to remove each string individually, and add new ones when I encounter new suffixes.  This is obviously far too cumbersome to set up and manage.  Can anyone suggest a more elegant way to trim all of these suffixes?

 

Sample of the data I'm working with:

 

 

Initial DataData I Need
CORE STRING TO KEEP1 TRIM1CORE STRING TO KEEP1
CORE STRING TO KEEP22 TRIM2 xxCORE STRING TO KEEP22
CORE STRING TO KEEP333 TRIM3 yy yCORE STRING TO KEEP333
CORE STRING TO KEEP4444 TRIM4 ZCORE STRING TO KEEP4444
CORE STRING TO KEEP55555 ALSO KEEP1CORE STRING TO KEEP55555 ALSO KEEP1
CORE STRING TO KEEP666666 ALSO KEEP2CORE STRING TO KEEP666666 ALSO KEEP22
3 REPLIES 3
alexnajm
18 - Pollux
18 - Pollux

If you have the list, use a Find Replace tool!

OllieClarke
16 - Nebula
16 - Nebula

@Rob48 If there's a pattern to what you need to trim/keep then you might be able to do this with a RegEx. Based on your example above, the following would work with the RegEx tool in parse mode:

(.*KEEP\d+)

Which will keep everything up to the final KEEP and its attached numbers

binu_acs
21 - Polaris

@Rob48 using regex_replace() function

binu_acs_0-1762448642845.png

 

Labels
Top Solution Authors