The full sample project is at the bottom of this post.
This can be handled using the keepbefore() and keepafter() functions. The functions allow specifying the index of the separator. A negative index counts from the end. In this case
keepafter("name1/name2/name3/55", "/", -1) returns "55"
Then we can check if the last segment is numeric using the isnumeric() function:
isnumeric(keepafter("name1/name2/name3/55", "/", -1)) returns TRUE.
Now we can identify if the last segment is numeric or not. If yes, then we can replace the last slash with a special separator (e.g. ':::'
), split the text into lines, then replace the special separator back with a slash.
The "Repeat rows" action can handle it with a bit of arithmetics.
That is doable too using the "Split delimited text into rows" and "Split delimited text into columns" actions.
Here is the full example project:
parse-text.morph (8.5 KB)