# Split String - after time and before dashes

**URL:** <https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797>\
**Category:** Studio\
**Tags:** question, system, activities\
**Created:** [May 5, 2022, 5:36am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797 "2022-05-05T05:36:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![chauhan.rachita30](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chauhan.rachita30/32/176728_2.png) [@chauhan.rachita30](https://forum.uipath.com/u/chauhan.rachita30)\
**Post date:** [May 5, 2022, 5:36am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/1 "2022-05-05T05:36:52Z")

</div>

I have the following string (its a comment box):

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

I need to retrieve the first message after the date and time and ending with the dashed line ----------.  
Can anyone guide on how to split it.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Rahul\_Unnikrishnan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahul_unnikrishnan/32/464046_2.png) [@Rahul\_Unnikrishnan](https://forum.uipath.com/u/Rahul_Unnikrishnan)\
**Post date:** [May 5, 2022, 5:43am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/2 "2022-05-05T05:43:35Z")

</div>

You can use the Split command for doing this. ErrorMsg is the variable holding this message.

**Split(ErrorMsg,“–”)[0]**

---

<div class="post-metadata">

**Author:** ![ushu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ushu/32/463480_2.png) [@ushu](https://forum.uipath.com/u/ushu)\
**Post date:** [May 5, 2022, 5:43am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/3 "2022-05-05T05:43:38Z")

</div>

@chauhan.rachita30 Try using regex

```auto
Encountered the following exception.*[\n\r]+.*

```

---

<div class="post-metadata">

**Author:** ![ushu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ushu/32/463480_2.png) [@ushu](https://forum.uipath.com/u/ushu)\
**Post date:** [May 5, 2022, 6:15am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/4 "2022-05-05T06:15:00Z")

</div>

@chauhan.rachita30 Use the below one, it would work. Check the attached workflow

[Example.zip](https://forum.uipath.com/uploads/short-url/jOwJ9kuZgreEMgngEyovxoEPYzO.zip) (3.0 KB)

```auto
Variable of type string Output = System.Text.RegularExpressions.Regex.Match(Input, "Encountered\s+the\s+following\s+exception.*[\n\r]+.*").ToString

```

**Input**

![Capture](https://global.discourse-cdn.com/uipath/original/4X/9/e/0/9e098b17e83024f9ce9fc2f69086d8db0d99f02e.png)

**Output**

![Capture1](https://global.discourse-cdn.com/uipath/original/4X/5/2/c/52c6e54030ef540af3b6b60dd75ba002805b2e87.png)

---

<div class="post-metadata">

**Author:** ![Sanjit\_Pal1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sanjit_pal1/32/264837_2.png) [@Sanjit\_Pal1](https://forum.uipath.com/u/Sanjit_Pal1)\
**Post date:** [May 5, 2022, 6:20am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/5 "2022-05-05T06:20:20Z")

</div>

Hey @chauhan.rachita30,

1. You can assign the text in one variable.
2. In the second variable you can assign **System.Text.RegularExpressions.Regex.Match(strText,“exception._[\n\r]+._”).Groups(0).ToString**  
where **strText** is the whole text.  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/b/1/7b17db74e1dbfa2b3b7b25ee9cf63ff56cc315e1.png)

Thanks,  
Sanjit

---

<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:** [May 5, 2022, 8:35am UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/6 "2022-05-05T08:35:05Z")

</div>

the small Pattern:  
`Encountered[\s\S]*?(?=\-{3,})`

---

<div class="post-metadata">

**Author:** ![chauhan.rachita30](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chauhan.rachita30/32/176728_2.png) [@chauhan.rachita30](https://forum.uipath.com/u/chauhan.rachita30)\
**Post date:** [May 5, 2022, 3:34pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/7 "2022-05-05T15:34:10Z")

</div>

It can start with anything, not specifically “Encountered”. Thanks

---

<div class="post-metadata">

**Author:** ![chauhan.rachita30](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chauhan.rachita30/32/176728_2.png) [@chauhan.rachita30](https://forum.uipath.com/u/chauhan.rachita30)\
**Post date:** [May 5, 2022, 3:35pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/8 "2022-05-05T15:35:36Z")

</div>

It can start with anything, not specifically “Encountered”. Thanks

---

<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:** [May 5, 2022, 4:24pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/9 "2022-05-05T16:24:57Z")

</div>

just share with us some more patterns with the variations. Thanks

---

<div class="post-metadata">

**Author:** ![chauhan.rachita30](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chauhan.rachita30/32/176728_2.png) [@chauhan.rachita30](https://forum.uipath.com/u/chauhan.rachita30)\
**Post date:** [May 5, 2022, 4:33pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/10 "2022-05-05T16:33:49Z")

</div>

It can be any message, I just need the first message after the date and before the dashed line.

---

<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:** [May 5, 2022, 4:47pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/11 "2022-05-05T16:47:52Z")

</div>

better with samples, but you can try following quick shot:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/0/e/1/0e14eb6ae13d42d671ee6975e51bd6e76d55867f.png)  
refering to group 1

![grafik](https://global.discourse-cdn.com/uipath/original/4X/5/c/6/5c61a9c7042656f52ed78949f3d9487ac737ec27.png)  
strPattern = `(?:[\d\/\: APM]+)([\s\S]*?)(?=\-{3,})`

strResult =  
`System.Text.RegularExpressions.Regex.Match(yourTextVar, strPattern).Groups(1).Value`

---

<div class="post-metadata">

**Author:** ![chauhan.rachita30](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chauhan.rachita30/32/176728_2.png) [@chauhan.rachita30](https://forum.uipath.com/u/chauhan.rachita30)\
**Post date:** [May 5, 2022, 6:55pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/12 "2022-05-05T18:55:48Z")

</div>

> [@ppr](#):
>
> System.Text.RegularExpressions.Regex.Match(yourTextVar, strPattern).Groups(1).Value

Thanks a ton!!!

---

<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:** [May 8, 2022, 6:56pm UTC](https://forum.uipath.com/t/split-string-after-time-and-before-dashes/420797/13 "2022-05-08T18:56:42Z")

</div>

Closed on May 8, 2022, 6:56pm UTC

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