How to split a long string into two line item

Hi all,

I have a long string. please check the below string.

\TRF ALCALA NORTE MULTI \NOT PROVIDED \PAGO FRAS.
18/10/2023 \ \TRFabc
\TRF CINES VALLEAGUADO SLB80781503 \NOT PROVIDED \EXHIBICION PELICULAS 2023 \ \TRFabc
\TRF ZARAFILMS S.A.

from above string I need to split and create different line items and need to store in a variable. output should be below:

1)\TRF ALCALA NORTE MULTI \NOT PROVIDED \PAGO FRAS.
18/10/2023 \ \TRFabc

2)\TRF CINES VALLEAGUADO SLB80781503 \NOT PROVIDED \EXHIBICION PELICULAS 2023 \ \TRFabc

No 1 and 2 are should be the output.

Kindly help me how I can split the string and get as a two line item.

thanks in advance

Hi,
How are you getting this string (from txt or csv or any other sources)& on what logic you are splitting?

I am getting this data from an excel file. First i am taking the data by using for each loop - row(“column”).tostring

After that I need to split.

Hi @roysupriya21

Can you try this one

lineItems = System.Text.RegularExpressions.Regex.Split(inputString, “(?=\TRF)”)

Hi @roysupriya21

create an array variable of type String

then

array_string = System.Text.RegularExpressions.Regex.Split(text, "(?=\n[\\TRF])")

To access the lines

array_string(0)
\TRF ALCALA NORTE MULTI \NOT PROVIDED \PAGO FRAS.
18/10/2023 \ \TRFabc

array_string(1)
\TRF CINES VALLEAGUADO SLB80781503 \NOT PROVIDED \EXHIBICION PELICULAS 2023 \ \TRFabc

array_string(2)
\TRF ZARAFILMS S.A.

The split occurs for each line starting with \TRF

it is showing error

Assign: parsing “(?=\TRF)” - Unrecognized escape sequence \T.

image

@roysupriya21

use this on

(?=\n[\\TRF])

Hi,

Try this one.
BlankProcess1.zip (143.1 KB)

still getting error : Assign: parsing “(?=\n[\TRF]” - Not enough )'s.

Hi @roysupriya21

Its missing characters

(?=\n[\TRF] incorrect 

(?=\n[\\TRF])  correct 

Thank you so much. It is perfectly working now.

1 Like

Glad to help @roysupriya21

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.