# Split dynamical string

**URL:** <https://forum.uipath.com/t/split-dynamical-string/14271>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [October 24, 2017, 1:46pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271 "2017-10-24T13:46:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venkatp](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@Venkatp](https://forum.uipath.com/u/Venkatp)\
**Post date:** [October 24, 2017, 1:46pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271/1 "2017-10-24T13:46:41Z")

</div>

hi

actual str=“123-456-6789”

i need to split like this dynamically

## str1=“123” str2=“456” str3=“6789”

if i add string  
str=1234-2345-123

it should disp  
str1=“1234”  
str2=“2345”  
str3=“123”

pls send me how to split and save it to another variables

tq

---

<div class="post-metadata">

**Author:** ![Poovarasan2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/poovarasan2/32/22560_2.png) [@Poovarasan2](https://forum.uipath.com/u/Poovarasan2)\
**Post date:** [October 24, 2017, 2:01pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271/2 "2017-10-24T14:01:15Z")

</div>

@Venkatp,  
Use Regex Match “\d”

Try the below link…

> **[regex101: build, test, and debug regex](https://regex101.com/)**
>
> Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

---

<div class="post-metadata">

**Author:** ![Mohan\_R](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@Mohan\_R](https://forum.uipath.com/u/Mohan_R)\
**Post date:** [October 24, 2017, 2:15pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271/3 "2017-10-24T14:15:46Z")

</div>

you can use Split –  
example:  
data.Split({“\*\*\*”},stringsplitoptions.None).ToArray

---

<div class="post-metadata">

**Author:** ![Venkatp](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@Venkatp](https://forum.uipath.com/u/Venkatp)\
**Post date:** [October 24, 2017, 2:27pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271/4 "2017-10-24T14:27:45Z")

</div>

not working can you pls send xaml file

---

<div class="post-metadata">

**Author:** ![ClaytonM](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/claytonm/32/555957_2.png) [@ClaytonM](https://forum.uipath.com/u/ClaytonM)\
**Post date:** [October 24, 2017, 3:28pm UTC](https://forum.uipath.com/t/split-dynamical-string/14271/5 "2017-10-24T15:28:32Z")

</div>

One simple way is to use .Split using the character that’s consistent like the dash.

**arrString = str.Split("-"c)**

Then run that through a loop to extract each element and process.

**For each str In arrString**  
**Message Box str**

EDIT:  
Or instead just store each element directly without a loop, like,  
**str1 = arrString(0)**  
**str2 = arrString(1)**  
**str3 = arrString(2)**

* * *

If the character can change other than a dash or if there are random alpha/special characters then you might consider using System.Text.RegularExpressions.Regex.Match( ) with a pattern

Hope that helps further.

Regards.

---

<div class="post-metadata">

**Author:** ![Ajithkumar\_P](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ajithkumar_p/32/21863_2.png) [@Ajithkumar\_P](https://forum.uipath.com/u/Ajithkumar_P)\
**Post date:** [October 25, 2017, 4:26am UTC](https://forum.uipath.com/t/split-dynamical-string/14271/6 "2017-10-25T04:26:25Z")

</div>

@Venkatp

Hi vengat,  
try this [Main.xaml](https://global.discourse-cdn.com/uipath/original/2X/c/c37167678667927d03bbd95e98531606be0fe7fe.xaml) (13.3 KB)

---

<div class="post-metadata">

**Author:** ![Hemanth](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@Hemanth](https://forum.uipath.com/u/Hemanth)\
**Post date:** [October 25, 2017, 4:44am UTC](https://forum.uipath.com/t/split-dynamical-string/14271/7 "2017-10-25T04:44:15Z")

</div>

Hi, @Venkatp  
Try this statement in Assign activity  
variable=Regex.Matches(yourString,“\d+”)  
Before that you need to import **System.Text.RegularExpression** in import panel  
Then in for each loop iterate the variable…  
you can achieve that…  
**Regards,**

---

<div class="post-metadata">

**Author:** ![Venkatp](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@Venkatp](https://forum.uipath.com/u/Venkatp)\
**Post date:** [October 25, 2017, 5:52am UTC](https://forum.uipath.com/t/split-dynamical-string/14271/8 "2017-10-25T05:52:10Z")

</div>

thank you all
