I have a data in excel ajay 23/4/22 ID123-6767
So i only need ajay ID123
I have tried like
Current(“column name”).ToString.Split(" “c)(0)+” “+Current(“column name”).ToString.Split(” "c)(2)
So im getting a O/P as ajay ID123-6767
So here in 2nd index its compltly taking the whole value so in this scenario where single space and delimeter - is involved how to seperate them by split
To extract “ajay ID123” from the string “ajay 23/4/22 ID123-6767” when there are spaces and a hyphen involved, you’ll need to perform the split operation in two steps. First, split by spaces to isolate “ID123-6767”, and then split by the hyphen to separate “ID123”. Here’s how you can do it:
Assuming CurrentRow is a DataRow and you are within a For Each Row activity in UiPath:
namePart As String = CurrentRow(“column name”).ToString.Split(" “c)(0)
idPart As String = CurrentRow(“column name”).ToString.Split(” “c)(3).Split(”-"c)(0)
result As String = namePart + " " + idPart
To extract “ajay ID123” from the string “ajay 23/4/22 ID123-6767” when there are spaces and a hyphen involved, you’ll need to perform the split operation in two steps. First, split by spaces to isolate “ID123-6767”, and then split by the hyphen to separate “ID123”. Here’s how you can do it:
Assuming CurrentRow is a DataRow and you are within a For Each Row activity in UiPath:
In this code:
Split(" "c)(0) takes the first part of the split by space, which should be “ajay”.
Split(" "c)(3) gets the fourth part of the split by space, which should be “ID123-6767”.
Split("-"c)(0) then splits “ID123-6767” by the hyphen and takes the first part, which should be “ID123”.
The final result string will concatenate “ajay” and “ID123” with a space in between.
In UiPath, you can use an Assign activity to perform these operations and store the result in a variable:
Add an Assign activity: namePart = CurrentRow("column name").ToString.Split(" "c)(0)
Add another Assign activity: idPart = CurrentRow("column name").ToString.Split(" "c)(3).Split("-"c)(0)
Finally, concatenate both parts: result = namePart + " " + idPart