Fun with string functions
I do a lot of string functions to look at URLs. If I want to use a SUBSTRING and INSTR Function what's the best way to move the end a dynamic number of characters?
EXAMPLE: I want to show the string after the 1st '=' and before 'the_end' in the 'big_string' field.
I wrote:
SUBSTRING(`big_string`,INSTR(`big_string`,'=')+1,INSTR(`big_string`,'the-end')-INSTR(`big_string`,'='))
The above works but I'm getting an extra character at the end that preceeds 'the-end' that's different. I tried sticking -1 in a few different places and it broke. Thoughts?
Best Answer
-
Sure thing. So here is what I did to model your question:
I created this string (my garbage example) as a URL model of what I think you're looking for:
https://www.google.com?formula=yes&donewithstring=the-end
I then used your code example to parse it, and I think this will work the way you want (added in red below):
SUBSTRING(`big_string`,INSTR(`big_string`,'=')+1,(INSTR(`big_string`,'the-end')-1)-INSTR(`big_string`,'='))
2
Answers
-
MattRK - are you doing this string manipulation in a beastmode, Magic ETL, or SQL? My answer changes a bit depending on which environment you're in.
0 -
As a beast mode. In SQL it's less difficult.
0 -
Sure thing. So here is what I did to model your question:
I created this string (my garbage example) as a URL model of what I think you're looking for:
https://www.google.com?formula=yes&donewithstring=the-end
I then used your code example to parse it, and I think this will work the way you want (added in red below):
SUBSTRING(`big_string`,INSTR(`big_string`,'=')+1,(INSTR(`big_string`,'the-end')-1)-INSTR(`big_string`,'='))
2 -
That works great, this is a good way to repilcate a "MID" function until such time as one exists in a Beastmode.
1
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