Start Free Trial

Alteryx Designer Desktop Discussions

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

Trimming characters within an XML file

Birdman1971
7 - Meteor

Good morning 

 

I have an xml being produced by a legacy system that has a quirk - it has an ID code 35 characters long but i want to trim to 15 characters - this occurs multiple times in the file and i need to change each instance

 

So this will appear or a variant of multiple times - in order for consumption to another solution, it cannot exceed 15 characters , highlighted in red 

 

<EndToEndId >123451F4-C123-456C-B123-09E8C8F7ADD<

 

This is a snip from the file , there is obviously data above an below - I can change the format to txt if that helps. 

 

Appreciate some advice 

2 REPLIES 2
DataNath
17 - Castor
17 - Castor

Hey @Birdman1971, could you try the following in a Formula tool? Replacing [Input] with your actual field name.

 

Replace([Input], SubString([Input], FindString([Input], '<EndToEndId >')+13, 35), SubString([Input], FindString([Input], '<EndToEndId >')+13, 15))

 

apathetichell
20 - Arcturus

if this only occurs once per line something like regex_replace(field,"^(.*<EndToEndId>)(.[15])(.*)(</EndToEndId>.*)$","$1$2$4") should get you there.basically - get me everything including the xml field marker. get me the next 15 characters. get me everything after xml field..

Labels
Top Solution Authors