How to split a stringafter 16th line

Hi All,

Can some help me to solve this, I want to split a string after nth Line (row)

Thanks

@Hitesh1, I wonder if this would work:

first use an assign activity to split your string by newline:
arrVariable[] = YourStringVar.Split(Environment.NewLine.ToCharArray())

then get the length: arrVariable[].Length()

use a while loop to iterate through each line: while arrVariable[].Length() > Counter

You can have an array of String variables, and while iterating through each line. use the String.Insert() function to add the lines of text into a variable, and use an if statement to check when it gets to 16 move to the next string variable in an array and add lines of text to it…

so when you are done you will have an array of variables. you can use a for each to go through each variable and have an if to check if a String variable is not NullOrEmpty.

@Hitesh1
for quicker prototyping reason it is done on # instead of Environment.NewLine.

grafik
1: split on # and taking the splits after second occurence
2: split on # and taking the splits before second occurence
3: producing the string for splits after second # occurence
4: the sample string

2 Likes

Thanks for the solution

But actually i have a paragraph which i have to divide in small paras of 16 lines each

Do we have any other solution for the same

This worked for me , Thanks

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