Alteryx Designer Desktop Discussions

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

Regex Help (Extracting numbers between parentheses)

mvtthewcornelison
7 - Meteor

Hi Alteryx Community,

 

How can I replace all of the numbers between a parentheses which contain a number to nothing. For example:

 

CURRENT ----> RESULT...

 

Test company 123 (100%) ----> Test company 123

Test company 456 (i.e. tc456) (200%) ----> Test company 456

Test Company (TC) Holding AB (46,714,779 COMMON_SHARES) ----> Test Company (TC) Holding AB 

 

So to further clarify the text I have to the right of ----> would be the current state, and the text to the right of ----> is what I would how to achieve after a regexreplace.

 

Thanks so much for your help!  Please let me know if you need further clarification. 

 

 

 

8 REPLIES 8
benakesh
12 - Quasar

Hi  @mvtthewcornelison ,

clipboard_image_0.png

 

Hope this helps .

 

Thableaus
17 - Castor
17 - Castor

Hi @mvtthewcornelison 

 

Would something like this work?

 

Trim(Regex_Replace([Field1], "\([^)]*?\d[^)]*?\)", ""))

 

Basically it means if it finds a number between parenthesis, we should replace this full expression (including the parenthesis), with nothing.

 

Use this expression with the Trim function in the Formula Tool.

 

Cheers,

mceleavey
17 - Castor
17 - Castor

Hi @mvtthewcornelison 

 

Hello Regex my old friend...

 

[(]\d+.+[)]|[(].+\d+.[)]

 

That should do it.

 

I've attached the workflow. Let me know it doesn't work.

 

M.

 

clipboard_image_0.png

 



Bulien

mvtthewcornelison
7 - Meteor

Thank you so much for your reply..very close - didn't work for :

 

Test Company, LLC (0 COMMON_SHARES) Test Company2, LLC (0 COMMON_SHARES)

mvtthewcornelison
7 - Meteor

This worked!! Thank you so much for your help 🙂 

mceleavey
17 - Castor
17 - Castor

Hi @mvtthewcornelison ,

 

It works for me.

Unless I've misunderstood what you need. I thought you wanted anything in parentheses that contained a number to be removed?

 

clipboard_image_0.png

 

M.



Bulien

mvtthewcornelison
7 - Meteor

@mceleavey I was hoping the output would be:

Test Company, LLC (0 COMMON_SHARES) Test Company2, LLC (0 COMMON_SHARES) ----> Test Company, LLC  Test Company2, LLC

 

I think I could have been more specific in my instructions / ask. And I should have included this record in my example. My apologies! Thanks for all your help.

mceleavey
17 - Castor
17 - Castor

Hi @mvtthewcornelison ,

 

I see. I n that case, you just need to make the clause "greedy":

 

[(]\d+.*?[)]|[(].*?\d+[)]

 

clipboard_image_0.png

 

New version attached.

 

M.



Bulien

Labels