I have 2 tab delimited (I replaced the tabs with → below) lines as in:
Line1Word1→Line1 Words2→→Line1Word3→→→Line1 Words4
→→Line2Word1→→Line2 Words2→→
Expected result
Line1Word1→Line1 Words2→Line2Word1→Line1Word3→Line2 Words2→→Line1 Words4
It's easy to see what the result should be, by copying the 3 lines in Excel
Line1
Line1Word1 Line1 Words2 Line1Word3 Line1 Words4
For this line I got
^(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)$
which will get the Groups 1, 2, 4 and 7. However I believe there must be a more generic way to obtain these that will account for any amount of groups.
Line2
Line2Words1 Line2 Words2
I could do the same here for Line 2 as above. Still need help on a more elegant way to get the groups, if I do not know how many to expect or where they are located.
RESULT
Line1Word1 Line1 Words2 Line2Words1 Line1Word3 Line2 Words2 Line1 Words4
Here I have no idea on how to combine the Groups from the 2 lines above as in:
\1(from Line1)\t\2(from Line1)\t\1(from Line2)\t\4(from Line1)...
I used regex sparingly over the years, but everything I tried for this got me nowhere. Any help will be greatly appreciated.
NOTE in response to Tripleee:
Data is formatted as follows:
Instead of Line1 and Line2, we will call them Array1 and Array2, which will contain multiple Lines, rows as described above. Both Arrays will have the same amount of rows
As in the example:
Array1 could have Indexes 1, 2, 4 and 7 only, with data in each row
Array2 could have Indexes 3 and 5 only, with data in each row
No index will have data in both arrays in any row
However, arrays could have data in different indexes every time the script runs, with more or less indexes every time
A variable containing ALL data, separated by |, can be created as in:
Row1Array1 | Row1Array2
Row2Array1 | Row2Array2
Row3Array1 | Row3Array2
...
Or data can be arranged in any other way that will help the use of regex.