# Extraction using regex

**URL:** <https://forum.uipath.com/t/extraction-using-regex/208927>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [April 4, 2020, 12:06pm UTC](https://forum.uipath.com/t/extraction-using-regex/208927 "2020-04-04T12:06:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 4, 2020, 12:06pm UTC](https://forum.uipath.com/t/extraction-using-regex/208927/1 "2020-04-04T12:06:42Z")

</div>

I have a text in which I need to extract the total,

Eg

Total : $100 abc  
Else  
Total abc def # 234

Here the only static thing is total, I need to extract the number and i don’t know what will be the text between the total and the number, whose are excluded  
In 1st sentence i want 100 In 2nd sentence I want 244

Help me with regex

---

<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:** [April 4, 2020, 2:16pm UTC](https://forum.uipath.com/t/extraction-using-regex/208927/2 "2020-04-04T14:16:25Z")

</div>

Hi,

If you want to extract only number, the following will work.

```
System.Text.RegularExpressions.Regex.Match(strData,"\d+").Value

```

or if there is other number and you need to extract your value from “Total”, the following helps you.

```
System.Text.RegularExpressions.Regex.Match(strData,"(?<=Total\D*)\d+").Value

```

Regards,

---

<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:** [April 4, 2020, 2:25pm UTC](https://forum.uipath.com/t/extraction-using-regex/208927/3 "2020-04-04T14:25:04Z")

</div>

@Sweety_Girl  
Have a look here and find the amount in group 3

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

or based on Yoichi’s approach with a different grouping  
`(?<=Total)\D*(\d+)` Value is in Group 1

---

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 6, 2020, 5:07am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/4 "2020-04-06T05:07:12Z")

</div>

I used the regex, but if the number is followed by comma and decimal points and number, how to do it …

Can we make it simple like,

first It will start taking where the digit starts (from total) and till the next white space

Help help with this regex

---

<div class="post-metadata">

**Author:** ![Pradeep\_Shiv](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pradeep_shiv/32/496519_2.png) [@Pradeep\_Shiv](https://forum.uipath.com/u/Pradeep_Shiv)\
**Post date:** [April 6, 2020, 5:36am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/5 "2020-04-06T05:36:44Z")

</div>

**(?\<=Total).[0-9]**\* this will help you in that condition!  
@Sweety_Girl

---

<div class="post-metadata">

**Author:** ![Pradeep\_Shiv](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pradeep_shiv/32/496519_2.png) [@Pradeep\_Shiv](https://forum.uipath.com/u/Pradeep_Shiv)\
**Post date:** [April 6, 2020, 5:46am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/6 "2020-04-06T05:46:10Z")

</div>

> [@Sweety\_Girl](#):
>
> Total : $100 abc  
> Else  
> Total abc def # 234

(?\<=Total\s.\s\p{Sc}).[0-9]\* this will give you **Total : $100 abc** 100 from this!  
(?\<=Total\s[A-Za-z\s]_\#)._ this will give you **Total abc def # 234** 234 from this!

Cheers @Sweety_Girl

---

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 6, 2020, 5:57am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/7 "2020-04-06T05:57:38Z")

</div>

Need only 1 regex for all types

---

<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:** [April 6, 2020, 6:19am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/8 "2020-04-06T06:19:57Z")

</div>

Hi,

> I used the regex, but if the number is followed by comma and decimal points and number, how to do it …

How about the following?

```
System.Text.RegularExpressions.Regex.Match(strData,"(?<=Total\D*)[.,\d]+").Value

```

Regards,

---

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 6, 2020, 6:34am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/9 "2020-04-06T06:34:40Z")

</div>

semi colon and dot are optional…

like

Total: 4,589.56  
Total abc; fhsi 568.5  
Total # 678  
Total 6,748,953.78

can we take Stating from the number till the space

---

<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:** [April 6, 2020, 7:39am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/10 "2020-04-06T07:39:14Z")

</div>

@Sweety_Girl  
Give a try on  
(?\<=Total)\D\*([\d,,.]\*)

and take value from group1 from each match

![grafik](https://global.discourse-cdn.com/uipath/original/3X/f/4/f481abff3981426c8de83e96c0ab19bd37719a02.png)

---

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 6, 2020, 10:11am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/11 "2020-04-06T10:11:13Z")

</div>

How to take the group1 in matches activity…

I am using this in matches and I am getting the output as the full match

---

<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:** [April 6, 2020, 10:22am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/12 "2020-04-06T10:22:24Z")

</div>

@Sweety_Girl  
Example of accesing Group1 for the first match  
 ![grafik](https://global.discourse-cdn.com/uipath/original/3X/e/4/e411466667570b8a4e1e70404bb219a4f5c39c01.png)

---

<div class="post-metadata">

**Author:** ![Sweety\_Girl](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sweety_girl/32/63415_2.png) [@Sweety\_Girl](https://forum.uipath.com/u/Sweety_Girl)\
**Post date:** [April 6, 2020, 10:26am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/13 "2020-04-06T10:26:50Z")

</div>

Thank you so much

---

<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 9, 2020, 10:26am UTC](https://forum.uipath.com/t/extraction-using-regex/208927/14 "2020-04-09T10:26:54Z")

</div>

Closed on April 9, 2020, 10:26am UTC

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