# Doubt in Split Function

**URL:** <https://forum.uipath.com/t/doubt-in-split-function/413999>\
**Category:** RPA Discussions\
**Tags:** coding\
**Created:** [April 10, 2022, 4:06pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999 "2022-04-10T16:06:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 10, 2022, 4:06pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/1 "2022-04-10T16:06:52Z")

</div>

Hi, I am a UiPath Beginner. Please help me with the below query.

“Alberto smith\r\n2 scored 30\r\ngoals in 21 games” This is my Input String and I need the output as “Alberto smith scored 30” using Split Fuction.

Here Two delimiters are there one is Space and slash

Please help me to split

---

<div class="post-metadata">

**Author:** ![jack.chan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jack.chan/32/176616_2.png) [@jack.chan](https://forum.uipath.com/u/jack.chan)\
**Post date:** [April 10, 2022, 4:08pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/2 "2022-04-10T16:08:24Z")

</div>

you want to split to

Alberto smith scored 30  
and  
“goals in 21 games” ?

---

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 10, 2022, 4:10pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/3 "2022-04-10T16:10:18Z")

</div>

Thanks for your reply. No I need only “Alberto Smith scored 30” from the input

---

<div class="post-metadata">

**Author:** ![jack.chan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jack.chan/32/176616_2.png) [@jack.chan](https://forum.uipath.com/u/jack.chan)\
**Post date:** [April 10, 2022, 4:14pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/4 "2022-04-10T16:14:57Z")

</div>

> [@sharu\_priya](#):
>
> Alberto smith\r\n2 scored 30\r\ngoals in 21 games

can you try this

`System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(0)+ System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(1)`

[test11.xaml](https://forum.uipath.com/uploads/short-url/pP8sg2VJfo6Kc1FPPc4rPTDrDMO.xaml) (6.8 KB)

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 10, 2022, 4:16pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/5 "2022-04-10T16:16:26Z")

</div>

Hey @sharu_priya

This can be done using string manipulation.

But that doesn’t make sense without some business rule to it.

What is the business rule here so that we can build logic for all scenarios.

Hope this helps.

Thanks  
#nK

---

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 10, 2022, 4:37pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/6 "2022-04-10T16:37:33Z")

</div>

Thanks much. But Why 2 is coming after smith. PFB screenshot for your reference

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/d/2/ad2692530acbe55a04f68377bfcc69928bf9b7fd.png)

---

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 10, 2022, 4:39pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/7 "2022-04-10T16:39:20Z")

</div>

Thanks for your reply nithin.  
It is just a small assignment given by my tutor.  
Please suggest me a solution with String Manipulation

---

<div class="post-metadata">

**Author:** ![ashwin.ashok](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashwin.ashok/32/300916_2.png) [@ashwin.ashok](https://forum.uipath.com/u/ashwin.ashok)\
**Post date:** [April 10, 2022, 5:14pm UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/8 "2022-04-10T17:14:54Z")

</div>

Hi @sharu_priya ,

Here is another solution →

![image](https://global.discourse-cdn.com/uipath/original/4X/a/d/1/ad1743558f59876855c2931e5251d5cc9c96ffa0.png)

![image](https://global.discourse-cdn.com/uipath/original/4X/6/6/3/663fed58f37b49bd67e663dff007060346d9fe8e.png)

```auto
System.Text.RegularExpressions.Regex.Replace(str_txtData,"\r?\n",chr(32))

```

[RemoveNewLines.xaml](https://forum.uipath.com/uploads/short-url/28FObmI9xEaYLSPHM0bLx3WQHtq.xaml) (5.3 KB)

**Kind Regards,  
Ashwin A.K**

---

<div class="post-metadata">

**Author:** ![jack.chan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jack.chan/32/176616_2.png) [@jack.chan](https://forum.uipath.com/u/jack.chan)\
**Post date:** [April 11, 2022, 1:22am UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/9 "2022-04-11T01:22:15Z")

</div>

> [@sharu\_priya](#):
>
> Thanks much. But Why 2 is coming after smith. PFB screenshot for your reference

Because theres a 2 in your input.

If you really want to remove the “2” you can do this

`System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(0) + System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(1).Replace("2", "")`

we are splitting by **two or more characters** \r\n so we have to use this function instead of the standard string.split  
`System.Text.RegularExpressions.Regex.Split`

The String.Split function only works with single characters which is why we cant use it here  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/9/8/c/98c8fd34fda555b1f956b2ca5d18a63a1a92540e.png)

---

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 12, 2022, 4:15am UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/10 "2022-04-12T04:15:08Z")

</div>

Sorry for the delay.

I have given now. Thanks much for your time:)

---

<div class="post-metadata">

**Author:** ![sharu\_priya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sharu_priya/32/179547_2.png) [@sharu\_priya](https://forum.uipath.com/u/sharu_priya)\
**Post date:** [April 12, 2022, 4:15am UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/11 "2022-04-12T04:15:48Z")

</div>

Thanks Ashwin

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 15, 2022, 4:16am UTC](https://forum.uipath.com/t/doubt-in-split-function/413999/12 "2022-04-15T04:16:11Z")

</div>

Closed on April 15, 2022, 4:16am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
