Regex Help (Extracting numbers between parentheses)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello Regex my old friend...
[(]\d+.+[)]|[(].+\d+.[)]
That should do it.
I've attached the workflow. Let me know it doesn't work.
M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This worked!! Thank you so much for your help 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @mvtthewcornelison ,
I see. I n that case, you just need to make the clause "greedy":
[(]\d+.*?[)]|[(].*?\d+[)]
New version attached.
M.
