Alteryx Designer Desktop Discussions

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

Replace similar characters in a string

Mario36
8 - Asteroid

Hi, What is the best approach to transform my Field Name to Field.

Currently, I approach to resolve this by adding a Text Input Tool with the second table and then use a Find and Replace to do the trick. I wanted to know the various approaches to resolve this.

 

Field NameField
summary______summary_
issuetype_self_____issuetype_self_
issuetype_id_____issuetype_id_
issuetype_description_____issuetype_description_
issuetype_iconurl_____issuetype_iconurl_
issuetype_name_____issuetype_name_
issuetype_subtask_____issuetype_subtask_
issuetype_avatarid_____issuetype_avatarid_
watches_self_____watches_self_
watches_watchcount_____watches_watchcount_
watches_iswatching_____watches_iswatching_
timespent______timespent_
created______created_
timeoriginalestimate______timeoriginalestimate_

 

 

FindReplace
___
____
_____
______
_______
________

 

8 REPLIES 8
AngelosPachis
16 - Nebula

Hi @Mario36 ,

 

One way to do that is by using a Regex tool configure to replace a pattern you define in the regular expression box with a replacement text

 

Your pattern can be _+, so that means 1 or more instances of an underscore and you want to replace that with a single underscore

AngelosPachis_0-1625173260676.png

 

Cheers,

 

Angelos

 

Mario36
8 - Asteroid

Thank You @AngelosPachis , this worked like a charm.

Any other approaches you can think of ?

apathetichell
19 - Altair

I like @AngelosPachis approach better - but if you need a hardcoded non-regex approach - you could do worse than:

trimright([Field Name],"_")+"_"

 

which removes the trailing "_" and then adds one back - because that's what you want it to do.

 

there  are numerous other approaches too (hey! You can tokenize everything and then use a multi-flow to find when the strings of "_"'s start then null() them and summarize/concatenate) but I'd stick with a simple regex/non-regex solution.

AngelosPachis
16 - Nebula

@Mario36 and an extra two besides what @apathetichell suggested which works great.

 

AngelosPachis_1-1625174830707.png

 

The formula is a bit of a cheat as it's a Regex Replace expression

apathetichell
19 - Altair

@AngelosPachisMazel Tov on the new badge! I'm still in the "maybe one day" stage...

Qiu
21 - Polaris
21 - Polaris

@Mario36 

Since it is a Find and Replace problem, how about the tool with the same name?

Capture1A.PNG

Mario36
8 - Asteroid

Unfortunately I did not want to use a Find and replace and a Text Input tool

AngelosPachis
16 - Nebula

Thank you @apathetichell ! We all have been at this stage, best of luck for whenever you feel ready and decide to give it a try!

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels