Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Replace Characters in the middel of a string

Drole
7 - Meteor

 Hi there, 

 

I have a data set that has a lot of coulmns, and I want to change the name of these columns, but i do not want to do i manually.

 

Drole_0-1594196138812.png

 

Is there a way were I can rename   Delta_2015, Delta 2016.... etc.   to be Delta_15, Delta_16,..., Delta_22. 

So I want to replace 20 for all colums with blank. 

 

Thanks

 

5 REPLIES 5
JosephSerpis
17 - Castor
17 - Castor

Hi @Drole you can with the Dynamic Rename I've mocked up a workflow let me know what you think?

ArtApa
Alteryx
Alteryx

In the attached example I changed Field Names from:

ArtApa_0-1594197041198.png

to:

ArtApa_1-1594197065262.png

Hope that helps.

 

Drole
7 - Meteor

Hi 

 

That helped, thanks 🙂   Could you explain the expression you used?  

 

Best regards 

 

 

JosephSerpis
17 - Castor
17 - Castor

Hi @Drole I used regex that matches a certain string pattern and then replaced it.  If you are new to Regex the Alteryx academy has some lessons on it. 

grazitti_sapna
17 - Castor

Hi @Drole , you can use this as well incase you just want to replace Delta_20 with Delta_.

grazitti_sapna_0-1594197909444.png

 

The regex expression used by @JosephSerpis 

\w{5}_\d{2} 

 

\w is used to parse the word character and {5} is the limit to fetch Delta

_ is used to match your character string.

\d is used to parse digit and {2} is the limit to fetch first two digits that is 20 from the string.\

Therefore, this expression will look for Delta_20 and will replace with Delta_ as used in the regex replace function.

Note: For better understanding you can visit regexr.com where you can learn about the regex.

I hope it helps.

Thanks.

 

Sapna Gupta
Labels