So I have a string (or text): Mark Jason Mark Jason Jason Mark
Or Amy John John Amy
and I would like to modify it so that all the duplicates are deleted
The first solution would be: Mark Jason
The second: Amy John
How do I do that?
So I have a string (or text): Mark Jason Mark Jason Jason Mark
Or Amy John John Amy
and I would like to modify it so that all the duplicates are deleted
The first solution would be: Mark Jason
The second: Amy John
How do I do that?
try this @anon40731888
inputString = “Mark Jason Mark Jason Jason Mark”
words = inputString.Split(’ ')
uniqueWords = words.Distinct()
outputString = string.Join(" ", uniqueWords)
Thank you but how do I do that in StudioX? where should I add the code?
Try adding it In assign activity
Hi @anon40731888
wordsArray = inputString.Split({" “}, StringSplitOptions.RemoveEmptyEntries)
distinctArray = wordsArray.Distinct().ToArray()
outputString = String.Join(” ", distinctArray)
Hope it helps!!
@anon40731888
Use set variable activity
BlankProcess.zip (2.6 KB)
Refer the above workflow @anon40731888
I have used
String.Join(" ", inputText.Split().Distinct())
Refer this
Use the below expression
String.Join(" ", strInput.Split(" "c).Distinct())
use the set variable activity to do this one in studio x
Hop it helps!!
To delete duplicates from an array of strings in UiPath StudioX, you can follow these steps:
Open UiPath StudioX and create a new project or open an existing one.
Drag and drop a “Set Variable” action onto the canvas.
In the “Variable” field, enter a name for the variable that will hold the result (e.g., resultArray
).
In the “Value” field, click on the “fx” button to open the Expression Editor.
In the Expression Editor, enter the following expression to remove duplicates from the array:
inputArray.Distinct().ToArray()
Replace inputArray
with the actual value or variable that contains your array of strings.
The Distinct()
function removes duplicates from the array, and ToArray()
converts the distinct values back into an array.
Click “OK” to close the Expression Editor.
If you want to store the result back into the original array variable, follow these steps:
resultArray
in this example).Continue with the rest of your workflow or add any additional actions as needed.
Here’s an example of the steps described above in UiPath StudioX:
In this example, the input array is {"Apple", "Banana", "Apple", "Orange", "Banana"}
and the output array will be {"Apple", "Banana", "Orange"}
with the duplicates removed.
Hope it works!!
strInput is name of my variable with names?
@anon40731888 absolutely correct it was a variable which the stores the text data.
let me try this now :)))))))
Okay @anon40731888
If you got this. Do mark it as solution which help to others.
BlankProcess.zip (2.6 KB)
Refer the above workflow @anon40731888
I have used
String.Join(" ", inputText.Split().Distinct())
Refer this i have sent the xaml to get clear understanding
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.