# Split string using UiPath

**URL:** <https://forum.uipath.com/t/split-string-using-uipath/634949>\
**Category:** Studio\
**Tags:** workflow-diff, question, studio\
**Created:** [October 11, 2023, 8:16am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949 "2023-10-11T08:16:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajnaraya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajnaraya/32/497124_2.png) [@ajnaraya](https://forum.uipath.com/u/ajnaraya)\
**Post date:** [October 11, 2023, 8:16am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/1 "2023-10-11T08:16:58Z")

</div>

“ACN - Test1 & Test2 15.09.23”  
I want to get Test1 , Test2 from this string. Can someone help to do this ?

---

<div class="post-metadata">

**Author:** ![Usha\_Jyothi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/usha_jyothi/32/274462_2.png) [@Usha\_Jyothi](https://forum.uipath.com/u/Usha_Jyothi)\
**Post date:** [October 11, 2023, 8:32am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/2 "2023-10-11T08:32:29Z")

</div>

[Sequence.xaml](https://forum.uipath.com/uploads/short-url/lil8Gj97o0igR9tTn0FRHxdSCLG.xaml) (6.3 KB)

hope this clarifies  
Usha

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [October 11, 2023, 8:34am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/3 "2023-10-11T08:34:24Z")

</div>

Starting with a simple Pattern  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/f/4/c/f4cf612fd31e09791228d4876afa89bf0e263a62.png)

![grafik](https://global.discourse-cdn.com/uipath/original/4X/4/e/7/4e70a3ac460bb831d6cb035cbe6008d2c2a77519.png)

[[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum](https://forum.uipath.com/t/cheatsheet-system-text-regularexpressions-regex/354895)

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [October 11, 2023, 8:52am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/4 "2023-10-11T08:52:41Z")

</div>

Hi @ajnaraya  
If the - and date will be constantly be there you can use like this

```auto
System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim

```

![image](https://global.discourse-cdn.com/uipath/original/4X/4/9/f/49f51affb9ff07e91f2abb04d0e1c259bff3d902.png)

This will give you like Test1 & Test2

If you want them in a single string variable you replace the &

```auto
System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim.Replace("&","")

```

If you want liek a array you split using &

```auto
System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim.Split("&"c)

```

Hope this Helps!!

Regards  
Sudharsan

---

<div class="post-metadata">

**Author:** ![pravallikapaluri](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pravallikapaluri/32/484755_2.png) [@pravallikapaluri](https://forum.uipath.com/u/pravallikapaluri)\
**Post date:** [October 11, 2023, 8:53am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/5 "2023-10-11T08:53:28Z")

</div>

Hi @ajnaraya

```auto
Assign: originalString = "ACN - Test1 & Test2 15.09.23"
Assign: stringArray = originalString.Split({" ", "&"c}, StringSplitOptions.RemoveEmptyEntries)
Assign: Test1 = stringArray(2)
Assign: Test2 = stringArray(4)

```

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![sasi\_poosarla](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sasi\_poosarla](https://forum.uipath.com/u/sasi_poosarla)\
**Post date:** [October 11, 2023, 9:01am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/6 "2023-10-11T09:01:49Z")

</div>

@ajnaraya

> System.Text.RegularExpressions.Regex.Matches(str,“\bTest[0-9]\b”).ToArray

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

---

<div class="post-metadata">

**Author:** ![neha.upase](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/neha.upase/32/402674_2.png) [@neha.upase](https://forum.uipath.com/u/neha.upase)\
**Post date:** [October 11, 2023, 9:46am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/7 "2023-10-11T09:46:13Z")

</div>

Hi, you can use below expression:

System.Text.RegularExpressions.Regex.Matches(“ACN - Test1 & Test2 15.09.23”, “Test\d+”)

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

---

<div class="post-metadata">

**Author:** ![lrtetala](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@lrtetala](https://forum.uipath.com/u/lrtetala)\
**Post date:** [October 11, 2023, 11:19am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/8 "2023-10-11T11:19:32Z")

</div>

Hi @ajnaraya

Try this

`(?<=\-\s+).*(?=\s+\&\s+)|(?<=\&\s+).*(?=\s+)`

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/7/1/671b317e082021b4f32853e04d8a047eb26dcefa.png)

---

<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:** [October 25, 2023, 10:36am UTC](https://forum.uipath.com/t/split-string-using-uipath/634949/9 "2023-10-25T10:36:21Z")

</div>

Closed on October 25, 2023, 10:36am UTC

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