How to get last second line of string?

Hello

in

StrVar:
“apple
orange
pear


water melon
kiwi”

I want to get water melon. (last second line)

How can I do it?

@Golf_Aquascape

try this

requiredstring = str.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries)(str.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries).Count-2)

cheers

Hi @Golf_Aquascape

Try this:
StrVar = StrVar.Split(Environment.NewLine)(StrVar.Split(Environment.NewLine).Count - 2)

Hi @Golf_Aquascape

Input1.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries).Reverse.Skip(1).FirstOrDefault()

Hi @Golf_Aquascape,

yourStr.Split(Environment.NewLine.ToArray)(yourStr.Split(Environment.NewLine.ToArray).Count-2)

Hope it helps!

Thanks!

Hi @Golf_Aquascape Once try this

strResult = StrVar.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)(StrVar.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries).Length - 2)

Hi, you can use below expression:

strValue =
“apple
orange
pear


water melon
kiwi”

Lines = strValue.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)

secondLine = lines(lines.Length - 2)