# Splitting string doesn't work as expected

**URL:** <https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020>\
**Category:** Studio\
**Tags:** immediate-panel, question, studio\
**Created:** [September 6, 2021, 10:22pm UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020 "2021-09-06T22:22:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev\_Dav](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dev_dav/32/181758_2.png) [@Dev\_Dav](https://forum.uipath.com/u/Dev_Dav)\
**Post date:** [September 6, 2021, 10:22pm UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/1 "2021-09-06T22:22:19Z")

</div>

Hello there, I want to split a String, the string is the following:

ExtractedText = “82 Habitaciones privadas”  
totalCuartos = ExtractedText.Split(" "c).First

I know that totalCuartos gives only the number. But when debugging it throws an error, because it doesn’t split the space between the number and the string, just the last one. I tried this in the immediate panel

![image](https://global.discourse-cdn.com/uipath/original/3X/b/e/be15735393422be9353ee4d528aad81d29ea62be.png)

I copied, pasted the symbol at position 2, but now doesn’t split last space  
As you can see, this doesn’t make any sense, unless the spaces are different, but I don’t know such thing. How could I split all the string?

Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [September 6, 2021, 11:27pm UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/2 "2021-09-06T23:27:29Z")

</div>

Hi

There might be some whitespace except character code 0x20.  
Can you try the following expression?

```
System.Text.RegularExpressions.Regex.Split(yourString,"\s+").First()

```

Regards,

---

<div class="post-metadata">

**Author:** ![prasath17](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath17/32/182331_2.png) [@prasath17](https://forum.uipath.com/u/prasath17)\
**Post date:** [September 6, 2021, 11:54pm UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/3 "2021-09-06T23:54:30Z")

</div>

@Dev_Dav - if you have notepad++ you can check the HEX value of that character to make sure where it is x20 …

 ![image](https://global.discourse-cdn.com/uipath/original/3X/f/1/f125c100eee0017471f24f88c1238fa35d925039.png)

![image](https://global.discourse-cdn.com/uipath/original/3X/9/8/980a7098c4c19e8ea1c3fde1631076585109795c.png)

---

<div class="post-metadata">

**Author:** ![Dev\_Dav](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dev_dav/32/181758_2.png) [@Dev\_Dav](https://forum.uipath.com/u/Dev_Dav)\
**Post date:** [September 7, 2021, 1:16am UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/4 "2021-09-07T01:16:24Z")

</div>

Hi there!  
That actually worked, but using RegEx Wizard with the (\s)+ expression. I don’t know how to execute that code in the actual workflow, but many thanks!!

![image](https://global.discourse-cdn.com/uipath/original/3X/7/9/7903de187ccec7d9d5a1bded4a8a4ce72c0506e0.png)

---

<div class="post-metadata">

**Author:** ![Dev\_Dav](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dev_dav/32/181758_2.png) [@Dev\_Dav](https://forum.uipath.com/u/Dev_Dav)\
**Post date:** [September 7, 2021, 1:17am UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/5 "2021-09-07T01:17:24Z")

</div>

I do have notepad++ but I don’t know how to do that ☹ sorry

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [September 7, 2021, 1:27am UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/6 "2021-09-07T01:27:59Z")

</div>

Hi,

> [@Dev\_Dav](#):
>
> I don’t know how to execute that code in the actual workflow

We can use it with Assign activity as the following, FYI.

![img20210907-5](https://global.discourse-cdn.com/uipath/original/3X/a/f/afdbd48ee47c093a810cd83b7da3691fc9d97088.png)

Regards,

---

<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:** [September 10, 2021, 1:28am UTC](https://forum.uipath.com/t/splitting-string-doesnt-work-as-expected/343020/7 "2021-09-10T01:28:10Z")

</div>

Closed on September 10, 2021, 1:28am UTC

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