# Extract certain text from string

**URL:** <https://forum.uipath.com/t/extract-certain-text-from-string/537495>\
**Category:** Studio\
**Tags:** system, activities\
**Created:** [April 20, 2023, 7:12am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495 "2023-04-20T07:12:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyingdragon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/flyingdragon/32/287509_2.png) [@flyingdragon](https://forum.uipath.com/u/flyingdragon)\
**Post date:** [April 20, 2023, 7:12am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/1 "2023-04-20T07:12:54Z")

</div>

Hi,

Need help. I want to extract some text from string and write to datatable

Example:  
**Input**  
Hi,  
Pls follow up.  
[Info] Please provide the information. AA,BB,CC,DD  
[Info] Please provide the information. CC,DD,AA,BB

**Output**  
For the first row of “[Info]”, write AA,BB,CC,DD under column 1. For the second row of “[Info]”, write CC,DD,AA,BB under column 2.

The input varies. There could be 2 rows and can be up to 15 rows. The common identifier is “[Info]” How do i ask the bot to perform this?

---

<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:** [April 20, 2023, 7:31am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/2 "2023-04-20T07:31:26Z")

</div>

Hi @flyingdragon - You can apply regex to get the data

```auto
System.Text.RegularExpressions.Regex.Matches(Input,"(?<=\[Info] Please provide the information.\s+).*")

```

Please check the below workflow and check how that helps

[SampleWorkflow.zip](https://forum.uipath.com/uploads/short-url/5bmzyPwtdhlJDOkjLnm1CZ0pszi.zip) (24.9 KB)

**Output**

![Picture1](https://global.discourse-cdn.com/uipath/original/4X/1/2/5/12516397c3a745fe23ba9757232889df58959879.png)

---

<div class="post-metadata">

**Author:** ![flyingdragon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/flyingdragon/32/287509_2.png) [@flyingdragon](https://forum.uipath.com/u/flyingdragon)\
**Post date:** [April 20, 2023, 7:49am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/3 "2023-04-20T07:49:48Z")

</div>

Is it possible to share the screenshots of the workflow here? I am unable to download any files in my work laptop. Appreciate much

---

<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:** [April 20, 2023, 8:22am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/4 "2023-04-20T08:22:33Z")

</div>

@flyingdragon -

1. Take Assign activity

```auto
Variable of type (System.Text.RegularExpression.MatchCollection) RegOutput = System.Text.RegularExpressions.Regex.Matches(Input,"(?<=\[Info] Please provide the information.\s+).*") 

```

Input variable has the input string data

1. Take **For Each** activity, assign a variable to **Index** property
2. Inside the loop, take **Add Data Column** activity, to add a column in data table (dynamically adding, you can change accordingly)

 ![Picture1](https://global.discourse-cdn.com/uipath/original/4X/5/e/9/5e948a516a59c742e4c28d14f2aae3920fba5c11.png)

1. Take **Add Data Row** activity to add a row in data table

 ![Picture2](https://global.discourse-cdn.com/uipath/original/4X/b/d/1/bd1f1080fa0857f05c5ac8d5d68bec21f4905e14.png)

1. Take **Assign** activity to insert the data into a row

```auto
DT.Rows(0).Item(Index) = currentItem

```

- **Index** is the variable assigned to Index property of For Each activity

1. Take **output data table** activity after **For Each** to convert the data table to text and finally print the text in a message box

 ![Picture3](https://global.discourse-cdn.com/uipath/original/4X/7/6/9/76918f2e3b6a4a2197948b4284e84ff8b368b42a.png)

---

<div class="post-metadata">

**Author:** ![flyingdragon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/flyingdragon/32/287509_2.png) [@flyingdragon](https://forum.uipath.com/u/flyingdragon)\
**Post date:** [April 20, 2023, 11:56pm UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/5 "2023-04-20T23:56:21Z")

</div>

Thanks for the help. But my For Each Activity looks different from yours. If i can only use my version, what should be the correct input?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/e/f/eef4c91cefc9a39c4c5d01a88238347cbeffee07.jpeg)

---

<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 21, 2023, 1:48am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/6 "2023-04-21T01:48:00Z")

</div>

@flyingdragon

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

---

<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:** [April 21, 2023, 5:54am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/7 "2023-04-21T05:54:38Z")

</div>

@flyingdragon - Let us know if you face any issues

---

<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 24, 2023, 5:55am UTC](https://forum.uipath.com/t/extract-certain-text-from-string/537495/8 "2023-04-24T05:55:11Z")

</div>

Closed on April 24, 2023, 5:55am UTC

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