Hello, I have string, that looks like this
@“[
““C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw1\””,
““C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw2v\””
]”
And I need to create a array variable with {“C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw1\”,“C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw2v\”}
I know I need to remove “[ and ]” but still the array contain string with two lines after activity FolderPaths.split(","c).
Can you help me?
Thanks
Hey @Katerina_Chabova
first remove unnecessary characters:
cleanString = jsonString.Replace("““", """").Replace("””", """").Replace("[", "").Replace("]", "").Trim
Then split into array:
folderPaths = cleanString.Split({","}, StringSplitOptions.None)
To trim each element you can also use:
folderPaths = folderPaths.Select(Function(p) p.Trim()).ToArray()
your string is close to a JSON string and we could parse it like normal JSON. But the string is not correctly escaping the backslashes. When you can adapt the source we can use it like essential JSON Processing.
Otherwise we would do:


But the string are in multiple lines. I.e. After run for each for that array, the first element is
@"
"“C:\Users\xxxx\OneDrive - KBC Group\UiPath\CA\TestingRaw1\”
and I want do testing if the path exist, In this case it is false, because it is on multiple lines. How can I fix that?
Assign -> inputString = "[ ""C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw1\"", ""C:\Users\xxx\OneDrive - KBC Group\UiPath\CA\TestingRaw2v\"" ]"
inputString is of DataType System.String
Assign -> folderPathsArray = inputString.Replace("[", "").Replace("]", "").Replace("""", "").Split(","c).Select(Function(s) s.Trim()).ToArray()
folderPathsArray is of DataType Array(System.String)
Message Box -> String.Join(" , ", folderPathsArray)
Hope it helps!!
Great, thank you ![]()
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
