How to Create List From String Variable

I have text file containing list of urls in each line. I read the file using Read text File assigned a string variable for its output.
how to convert the string variable (add urls of each line) to a list.

My intention is to use browser to navigate to each url. Is there any different way to make it work ?

Can you share the input file ?


the most simple and straightforward way to do it will be to use a For each activity as follow.
It will always that your files will always contain lines which are url’s.

For each each s as string in file.ReadAllLines(strPath)
‘Navigate logic’

If you want something more advance and with more error handling you can replace the ReadAlllines(strPath) by file.ReadAllLines(strPath).Select(Function(L) System.Text.RegularExpressions.Regex.Match(L,“(http|https):[^\s]*”).ToString)

This will extract from each line from the file the url content from it. If there is no url,it will be empty so you need to check if line is not empty when you will navigate.


Input File doesnt have much, here is example


Main.xaml (6.9 KB)

I have attached a file. Check it out.
The data is assigned to an array of strings. You can get each url by index number.

I am assuming that your input file contains data like

1 Like

Great. Thank you very much. It works. Can you suggest some tutorials for learning variable manipulation for uipath ?

1 Like

I would suggest you to take up the foundation course if you haven’t. Try making changes to the examples which are demonstrated in the videos.

1 Like


I have the same problem with a string but the separators are not lines but ;

So I want to convert my string “val1 ; val2 ; val3” to a list containing {val1,val2,val3}

Which code can I use?


Refering to the code above -

Instead of fileData.Split({System.Environment.NewLine}, StringSplitOptions.none) use
fileData.Split({“;”}, StringSplitOptions.none)