Extracting lines from a piece of text

Hi there,

I have multi-line text stored in a String, for example:-

--------------------------------------------------------------

X is a dog, Y is a cat. X lives in K, Y lives in M.

X is a friend of Y.

X goes to M and meets Y.<br>Y marries X and both live in K now.

--------------------------------------------------------------

I want to split this text (one cell in a row) to 4 rows, each containing the line with it's line number (additional column). i.e.

linenum_in_text        useful_text

1                                X is a dog, Y is a cat. X lives in K, Y lives in M.

2                                X is a friend of Y.

3                                X goes to M and meets Y.

4                                Y marries X and both live in K now.

 

I tried to use Java Snippet node, but it only creates one output row for each input row. I am not sure if we can create multiple output rows for one input row.

Is there a way to use Java Snippet (or similar nodes) to do similar things like GroupBy or Ungroup?

Thanks in advance.

 

 

 

Hi,

Of course that's possible! One way to do it:

  • Replace the <br> tags with newlines with a String Replacer (let it insert "\n")
  • Split rows into parts with a Cell Splitter, creating Collection cells (again, split at "\n")
  • Ungroup

Hi Marlin,

I have just tested your solution. It works exactly what you said, and what I wanted.

Grazie :-)