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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive