Need help to change string to array

Hello everyone,
I have string which contains
mystring: Field
ABC
XYZ
Field
Field
dcgd
ghi
Field
ASDF
I need to remove all “Field” from string and put rest of the string as array of strings like {ABC, XYZ, dcgd, ghi, ASDF}

Thanks in advance!

Hi @rathi.sham ,

Try the following expression:

yourStringVariable.Split(Environment.NewLine.tochararray, StringSplitOptions.RemoveEmptyEntries).Where(Function(x) x.Trim() <> "Field").ToArray()

Regards,

Thank you so much! that worked.

1 Like

Cheers @rathi.sham

@rathi.sham

Another way

say string is stored in str

then str.Replace("Field","").Split({Environment.Newline},StringSplitOptions.RemoveEmptyEntries)

cheers

thanks for the help, really appreciate it.

1 Like

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