Hi everyone,
I can’t seem to split a string into an array based on \n. I see that lots of people advide on using the Enviroment.NewLine method, but I can’t get it to work (it says I need to declare Enviroment). The string is extracted from a text file and the content of the text file is ever changing.
Hey,
You can use
Split(StrVar,Environment.newline)(0)
Split(StrVar,Environment.newline)(1)
Split(StrVar,Environment.newline)(2)
Where strVar is a string variable where you can store Input String
Thanks
alternatively you can use this, if you have trouble importing the environment class in your projects. (can’t think of a reason why that happens, but hey, lets think out of the box:
Split(StrVar, chr(13))(0)
Split(StrVar, chr(13))(1)
Split(StrVar, chr(13))(2)
assign
lineArray (array of string) = System.text.regularexpressions.regex.split(stringVar, environment.Newline)
then
use foreach activity to loop over the lines of lineArray
Doesn’t seem to work either.
Ok, now it seems to be working, BUT then I don’t understand how to get the single word. I wanted to print out Jack, i created a message box writing Text(0) and it gives me the single letter…
do this first @sebastiano_santini
declare variable lineArray ( array of string)
then assign
lineArray = System.text.regularexpressions.regex.split(Text, environment.Newline)
now lineArray(0)
will print Jack
I can’t get it to work. I’ll attch the workflow so you can see what im doing.
Thanks for the help btw!
Main.xaml (10.8 KB)
You can use the “read text file” activity instead of “Use Application”.
Regards,
MY
assign this to lineArray instead, then it should work
lineArray = System.Text.RegularExpressions.Regex.split(in_Text, "\n")
I changed from use application to read file text and it worked, no metter if i used environment.newline or “\n”. Do you have any idea why it doesn’t on use application?
i guess get text doesnt treat newlines as newlines, read text file does
if your input is a text file just use read text file
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.