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.
You can use
Where strVar is a string variable where you can store Input String
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:
lineArray (array of string) = System.text.regularexpressions.regex.split(stringVar, environment.Newline)
use foreach activity to loop over the lines of lineArray
you;re missing an “n”
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)
lineArray = System.text.regularexpressions.regex.split(Text, environment.Newline)
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”.
assign this to lineArray instead, then it should work
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.