How can I create a beastmode that will return the desired substring in a field?

Hi all,
I've given this multiple attempts and just can't seem to get it. I have a field called 'Destination' that I want to use in a Beastmode that will return the first substring of "B-FGI" or "FGI" in a value such as "Doe, John A-B-FGI-20.15.0003.B-FGI" or "Doe, John A-FGI-20.15.0003.B-FGI". I also want to create another Beastmode in that same value that will return the locator number and following sub inventory: "Doe, John A-B-FGI-20.15.0003.B-FGI". The substring can also end in "FGI" such as "Doe, John A-B-FGI-20.15.0003.FGI"
Note: Value lengths are inconsistent. The hyphen position and count is also inconsistent as I want to return "B-FGI" or "FGI". I will include some examples below and bold the substrings I'd like to extract. So far I've tried SPLIT_PART but since there's a '-' in between the substring so it does not seem to work. Functions such as REGEX, POSITION, INDEX do not seem to work in Domo or maybe I am using it wrong.
Column Name: Destination
1st beastmode
Doe, John A-B-FGI-20.17.0003.B-FGI
Walker, Mary C-FGI-19.12.0003.FGI
Doe, Jane-B-FGI-RLB.02.01.B-FGI
2nd beastmode
Doe, John A-B-FGI-20.17.0003.B-FGI
Walker, Mary A-FGI-19.12.0003.FGI
Doe, Jane-B-FGI-RLB.02.01.B-FGI
Best Answer
-
Because you have variable length in your string I'd recommend utilizing a formula tile in a Magic ETL to perform a regular expression.
FGI
REGEP_REPLACE(`Destination`, '^[^\-]*\-((\w\-)?FGI)-(\d{2}\.\d{2}\.\d{4}.*)$', '$1')
Tail end:
REGEX_REPLACE(`Destination`, '^[^\-]*\-((\w\-)?FGI)-(\d{2}\.\d{2}\.\d{4}.*)$', '$3')
You can play around with the regular expressions at websites like
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Answers
-
Because you have variable length in your string I'd recommend utilizing a formula tile in a Magic ETL to perform a regular expression.
FGI
REGEP_REPLACE(`Destination`, '^[^\-]*\-((\w\-)?FGI)-(\d{2}\.\d{2}\.\d{4}.*)$', '$1')
Tail end:
REGEX_REPLACE(`Destination`, '^[^\-]*\-((\w\-)?FGI)-(\d{2}\.\d{2}\.\d{4}.*)$', '$3')
You can play around with the regular expressions at websites like
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive