# String Method doubt

**URL:** <https://forum.uipath.com/t/string-method-doubt/717193>\
**Category:** Studio\
**Tags:** string-method, system\
**Created:** [February 4, 2024, 8:48pm UTC](https://forum.uipath.com/t/string-method-doubt/717193 "2024-02-04T20:48:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_rocks](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajay_rocks/32/459213_2.png) [@Ajay\_rocks](https://forum.uipath.com/u/Ajay_rocks)\
**Post date:** [February 4, 2024, 8:48pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/1 "2024-02-04T20:48:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pikorpa](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pikorpa/32/548059_2.png) [@pikorpa](https://forum.uipath.com/u/pikorpa)\
**Post date:** [February 4, 2024, 8:52pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/2 "2024-02-04T20:52:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shantanu\_chande](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shantanu_chande/32/443855_2.png) [@shantanu\_chande](https://forum.uipath.com/u/shantanu_chande)\
**Post date:** [February 4, 2024, 9:26pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/3 "2024-02-04T21:26:06Z")

</div>

> [@Ajay\_rocks](#):
>
> ajay 23/4/22 ID123-6767

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

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [February 4, 2024, 10:40pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/4 "2024-02-04T22:40:01Z")

</div>

Hi @Ajay_rocks

Try the below syntax:

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

```

Regards

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [February 4, 2024, 11:02pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/5 "2024-02-04T23:02:12Z")

</div>

Hi @Ajay_rocks

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

```

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/9/1/e91fdc4fbd278b90c2edc40b08a455f54d961e32.png)

Regards

---

<div class="post-metadata">

**Author:** ![Nawazish\_Ahmad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nawazish_ahmad/32/262848_2.png) [@Nawazish\_Ahmad](https://forum.uipath.com/u/Nawazish_Ahmad)\
**Post date:** [February 5, 2024, 5:33am UTC](https://forum.uipath.com/t/string-method-doubt/717193/6 "2024-02-05T05:33:04Z")

</div>

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 🙂  
Cheers!!

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 5, 2024, 5:36am UTC](https://forum.uipath.com/t/string-method-doubt/717193/7 "2024-02-05T05:36:49Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![rlgandu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rlgandu/32/488436_2.png) [@rlgandu](https://forum.uipath.com/u/rlgandu)\
**Post date:** [February 5, 2024, 5:39am UTC](https://forum.uipath.com/t/string-method-doubt/717193/8 "2024-02-05T05:39:00Z")

</div>

@Ajay_rocks

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

```

---

<div class="post-metadata">

**Author:** ![Ajay\_rocks](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajay_rocks/32/459213_2.png) [@Ajay\_rocks](https://forum.uipath.com/u/Ajay_rocks)\
**Post date:** [February 5, 2024, 5:25pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/9 "2024-02-05T17:25:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [February 5, 2024, 6:49pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/10 "2024-02-05T18:49:34Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![pikorpa](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pikorpa/32/548059_2.png) [@pikorpa](https://forum.uipath.com/u/pikorpa)\
**Post date:** [February 5, 2024, 10:58pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/11 "2024-02-05T22:58:16Z")

</div>

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

[Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum](https://forum.uipath.com/t/forum-faq-how-to-mark-a-post-as-a-solution/338723)

---

<div class="post-metadata">

**Author:** ![srinivasmarneni](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@srinivasmarneni](https://forum.uipath.com/u/srinivasmarneni)\
**Post date:** [February 5, 2024, 11:23pm UTC](https://forum.uipath.com/t/string-method-doubt/717193/12 "2024-02-05T23:23:27Z")

</div>

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`
