Using regexp for pulling multiple values out a text string
Hello, I need some help pulling out email addresses from a text string.
My goal is to place these multiple emails listed in the 'Description' column in a separate column, where they'll be separated by ','. Is there way for the search to end before the Sent Date info?
Thank you!
Best Answer
-
Try something like this to make it a bit simpler:
REPLACE(REGEXP_REPLACE(SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2), '[^<]+<([^>]+>)', '$1'), '>', ',')
SPLIT_PART(``, 'Sent:', 1)
Gets evertying in your string before 'Sent: ' - drops everything after it
SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2)
Gets the entire text in between the To: and Sent: values so you're left with just the email addresses and the aliases
REGEXP_REPLACE(…, '[^<]+<([^>]+>)', '$1')
Finds all occurrences of the email addresses and any values outside of the < > and drops it in favor of what's in the < >. This keeps the trailing > so we can replace it with REPLACE in the last step with commas.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Answers
-
Are you wanting the From and To both to be included or just the To? Will the From and To fields only have a single email or would there be multiple emails?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
@GrantSmith I'm needing just the emails that would be listed in the To field. The emails listed in To field can have multiple email addresses listed. Thank you for your help!
0 -
Try something like this to make it a bit simpler:
REPLACE(REGEXP_REPLACE(SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2), '[^<]+<([^>]+>)', '$1'), '>', ',')
SPLIT_PART(``, 'Sent:', 1)
Gets evertying in your string before 'Sent: ' - drops everything after it
SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2)
Gets the entire text in between the To: and Sent: values so you're left with just the email addresses and the aliases
REGEXP_REPLACE(…, '[^<]+<([^>]+>)', '$1')
Finds all occurrences of the email addresses and any values outside of the < > and drops it in favor of what's in the < >. This keeps the trailing > so we can replace it with REPLACE in the last step with commas.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
@GrantSmith It worked, thank you!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive