Extract multiple sets of numbers from a single string
I am trying to extract two different sets of numbers from a string. I have tried substring and Regexp, but to no avail.
Examples of the stringss-
Possible string format #1
Company Name - 2024-07-01-2024-07-31 - GPPC - YTUBE - VYT - 63784 - 2782837 - 458573682 - [745-000121-003]
Possible string format #2
Company Name - 2024-07-01-2024-07-31 - GPPC - YTUBE - VYT - 63784 - 2782885 - 458573695
-
The only difference between the two possible formats is that the number on the end surrounded in brackets may not appear on some strings. In the example above, i would like to pull "2782837" or "2782885" and "458573682" or '458573695' respectively. What would be the best way to accomplish this in the ETL, using sql or the tiles or both?
Answers
-
If they're always in the same position with the same ' - ' separator you can use SPLIT_PART
SPLIT_PART(`string`, ' - ', 7) SPLIT_PART(`string`, ' - ', 8)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
Hi Grant, awesome, thank you it did work for any of the strings ending in " [745-000121-003]" but it did not seem to work, if the string ended without the bracket [] e.g. 2782885 - 458573695. Do you know why that is and how I can make sure it works for both?
0 -
How did it not work? Did it return the wrong numbers or not return anything?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
It returned a blank field. I was trying to play around with it, but no luck. I am not sure why it only works for the strings that included the number inside the brackets.
0 -
I tried both expressions with both the strings in your example and it seemed to work in all cases. Are you certain that the exact string on which it isn't working is this one?
Company Name - 2024-07-01-2024-07-31 - GPPC - YTUBE - VYT - 63784 - 2782885 - 458573695
Randall Oveson <randall.oveson@domo.com>
0 -
Hi rco, perhaps the issue, is that the strings without the brackets are a bit shorter. Please see the examples below, would that effect it?
Community - 2.13 - 2.28 - 2962953 - 502020281
Company - 2.24 – 3. 30 – 2936712 - 503631860Thank you for you help.
0 -
I see what I did wrong. thank you guys for all your helP!
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 788 Beast Mode
- 78 App Studio
- 43 Variables
- 744 Automate
- 187 Apps
- 474 APIs & Domo Developer
- 67 Workflows
- 16 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive