Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Extract multiple items in brackets from string

DL1
5 - Atom

Hi everyone,

Happy new year, to start with!

 

Could someone help me extract all the items which are in brackets ( ) and move them to individual columns, as per the example below ? 

 

  • Source string (manually bolded items are the ones to extract) :

$whatever(abc_example1_spec)/Folder/$somethingelse("$value(abc_example2_name)","info type","en")/$whatever(example3_info)/$something(example4)

 

  • Target result to individual columns :

abc_example1_spec / abc_example2_name / example3_info / example4

 

Note that there might be different levels of brackets e.g. ("$value(abc_example2_name)","info type","en"), in which case I am only interested in items at the deepest level. I also do not know how many items are to be extracted from a string (4 in the example above, but there could be less or more).


I have found the following expression to use with RegEx but it only parses the last item in my string (.*)(?:\()(.*)(?:\))

 

Looking forward to testing your suggestions !

 

5 REPLIES 5
Avinash_K
8 - Asteroid

I am not a regex expert but i like playing around with it  . Try this pattern \(\w+\)  hopefully it will match your requirements .

papalow
8 - Asteroid

The solution below is not as efficient as a RegEx solution would be, but it does work.  

DL1
5 - Atom

this pattern works of course much better than mine, thanks !

though, I have to add the following formula (Replace(Replace([_CurrentField_],"(",""),")","")) in the multi field formula tool to get rid of the brackets.

thanks a lot !

DL1
5 - Atom

hi @papalow

 

It indeed works very well for one record, but I do have 100+ and I would need to add a few other tools in order to uniquely identify them and appropriately reassign the items found.

 

but thanks a lot, that is an interesting logic I will certainly use elsewhere!

papalow
8 - Asteroid

@DL1

You are welcome.  I am also working on a RegEx solution in between other things today.  Sometimes I find it faster to use several tools rather than perfect the RegEx syntax.  

Labels
Top Solution Authors