Alteryx Designer Desktop Discussions

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

replacing brackets with parentheses in every column title with regex or any formula

AshaCharis
7 - Meteor

Hi, I am trying to replace all brackets with parentheses in the columns titles of my excel sheet.

 

so title for each column looks like this to what I want:

 

amb t [c] --> amb_t(c)

amb t [f] --> amb _t(f)

t [s] --> t(s)

 

etc.

 

Can anyone help with this? this is my first time using regex to replacing special characters.

 

 

6 REPLIES 6
atcodedog05
22 - Nova
22 - Nova

Hi @AshaCharis 

 

You can use a formula like below

 

 

Replace(Replace([Input], "[", "("), "]", ")")

 

 

atcodedog05_0-1626714802863.png

 

Hope this helps : )

 

Maskell_Rascal
13 - Pulsar

As it has been pointed out to me recently that there is a contingent of those that want REGEX answers and only REGEX answers, I will offer an alternative solution using REGEX_Replace. This one is for you @apathetichell😁

 

 

REGEX_Replace([Input], '(\[)(.+)(\])','\($2\)' )

 

 

Maskell_Rascal_0-1626715997998.png

 

And once again the chaotic spirits of REGEX have been appeased.

 

Cheers!

Phil

 

atcodedog05
22 - Nova
22 - Nova

It says also any formula.

 

But you make a fair point @Maskell_Rascal 😎

AshaCharis
7 - Meteor

Thank you guys for the quick responses! my problem is that the titles I am looking at are in the actual field/record title.

 

So Input = amb_t[c] --> amb_t(c)

 

How do I make replace the column titles with parentheses without using the select tool to change every single one? (Lots of titles need to be replaced)

atcodedog05
22 - Nova
22 - Nova

Hi @AshaCharis 

 

Use the formula in the dynamic replace tool like below.

 

Workflow:

atcodedog05_0-1626716659862.png

 

Hope this helps : )

 

AshaCharis
7 - Meteor

Thank you so much! This worked!

Labels