Split() function action block

Dm114

Well-known member
Splits a string data separated by separator into an array. Equivalent to split(separator) function in javascript.

I tried your Block actions.

Unfortunately there are 2 limitations I found with what I use to use:
1⁰) If the string to remove (by the Replace action) contains special regex characters (such as . and/or * in my case), it doesn't work
2⁰) If one of the 'word' is missing between 2 separators, the loop stops and doesn't scan the rest of the line

I found (Googled) and interesting regex formula to extract (with 1 statement only) the Nth occurrence in a line. Here it is:
Code:
^(?:[^;]+;){[lv=n]}([^;]+)
where [lv=n] is the rank of the parameter/word you want to extract.

It can extract any kind of character between 2 separators (';' in my example), even empty strings. But you must know the maximum number of parameters/words to extract to limitate the loop to populate the array.

I'm sure you'll improve your nice macro! 👍
 

FrameXX

Well-known member
I tried your Block actions.

Unfortunately there are 2 limitations I found with what I use to use:
1⁰) If the string to remove (by the Replace action) contains special regex characters (such as . and/or * in my case), it doesn't work
2⁰) If one of the 'word' is missing between 2 separators, the loop stops and doesn't scan the rest of the line

I found (Googled) and interesting regex formula to extract (with 1 statement only) the Nth occurrence in a line. Here it is:
Code:
^(?:[^;]+;){[lv=n]}([^;]+)
where [lv=n] is the rank of the parameter/word you want to extract.

It can extract any kind of character between 2 separators (';' in my example), even empty strings. But you must know the maximum number of parameters/words to extract to limitate the loop to populate the array.

I'm sure you'll improve your nice macro! 👍

Updated!

I used this dumb replace function to catch any special regex characters:

Replace: (\.|\+|\*|\?|\^|\$|\(|\)|\[|\]|\{|\}|\\|\|)

With: \\$1
 
Last edited:
Top