String Method doubt

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

Hey @Ajay_rocks
try to use:
Current("column name").ToString.Split(" "c)(0) + " " + Current("column name").ToString.Split(" "c)(2).Split("-"c)(0)

1 Like

Hello @Ajay_rocks You can use Regular Expression to extract the data, if it is above format :
Regex - (?<=\d{1,2}/\d{1,2}/\d{2,4}\s)[A-Za-z0-9]+

Thanks

Hi @Ajay_rocks

Try the below syntax:

CurrentRow("column name").ToString.Split(" "c)(0) & " " & CurrentRow("column name").ToString.Split(" "c)(2).Split("-"c)(0)

Regards

Hi @Ajay_rocks

CurrentRow("column name").ToString.Split(" "c)(0) & " " & CurrentRow("column name").ToString.Split(" "c)(2).Split("-"c)(0)

Regards

Hi @Ajay_rocks

Try below expression

CurrentRow(“column name”).ToString.Split(" “c)(0) + " " + CurrentRow(“column name”).ToString.Split(” “c)(2).Split(”-"c)(0)

Hope it will helps you :slight_smile:
Cheers!!

@Ajay_rocks

As you have created most of it…you can add the below as well

CurrentRow("Col").ToString.Split(" "c)(0) + " " + currentRow("Col").ToString.Split(" "c)(2).Split("-"c)(0)

Cheers

@Ajay_rocks

Assign activity:
Result = Current("column name").ToString.Split(" "c)(0) + " " + Current("column name").ToString.Split("-"c)(0)

thank you all its worked by your answers I am glad that you guys are so supportive thank you ):

Hi @Ajay_rocks

If you find the solution for your query please mark my post as solution to close the loop or if you have any questions I’m happy to help.

Happy Automation!!

Hey @Ajay_rocks
Please choose the answer that was best for you and mark this answer as the solution :slight_smile:

Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

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:

  1. Add an Assign activity: namePart = CurrentRow("column name").ToString.Split(" "c)(0)
  2. Add another Assign activity: idPart = CurrentRow("column name").ToString.Split(" "c)(3).Split("-"c)(0)
  3. Finally, concatenate both parts: result = namePart + " " + idPart