I need to split a text into a fixed number of columns but want to keep the extra delimiters at the beginning.
For example, using the - delimiter if I got: 123-123-SOMETHING
I want to get two columns. Column A: 123-123 and column B: SOMETHING
Based on another answer I was thinking in a 3-step solution
Step 1 - Formula to reverse the string
Step 2 - Split to columns with delimiter, 2 columns and leaving extra columns in last column
Step 3 - Reverse back the two column string.
But I was trying to go for a one step solution probably using REGEX or other formulas.
Basically I'm trying to replicate the following function from PowerBI into a single step in Alteryx:
Does anyone have any insight to resolve using an alternate solution?
Solved! Go to Solution.
Hi @matiasb
Want to caveat I'm not an regex expert, but the below should work in regex parse mode:
(.*)-(.*)
Hi @matiasb
The regex to be used in a Regex tool parse mode would be something like this
(.*)\-([^\-]+)
(.*) : first all character before - .\- is used to escape - function
([^\-]+) : all character instead of - . this way it splits from the right most.
Workflow:
Hope this helps 🙂
Thanks. That work great.... guess will have to clean the dust on the REGEX manuals back from when I was learning Unix 😄
Appreciate your assistance
Fyi - if you wanted to combine your approach into one formula you could use:
trimleft(reversestring(regex_replace(reversestring([test]),"([!-]+).*","$1")),"-")
There should be an easier way using no matching characters to "-" and end of line $ - but I'm still working on it.