Regex to extract a number between a dynamic number

Hi, I’m struggling to extract this:
Example:

Invoice Amount 20,000.00 18,000.00

From the above i want to extract the 20,000.00 using regex but its dynamic, there may be any number of digits and also that 18,000.00 also dynamic we can have any no. of digits. The only static word is Invoice Amount. Please help me. Thanks

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Invoice Amount )[\d,]+").Value

Regards,

Hi @Yoichi Thanks for your suggestion but its taking only the 20,000 and .00 is not extracted

Hi,

Sorry,i had a mistake. How about the following?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Invoice Amount )[\d.,]+").Value
1 Like

Hi @padmapadh1895

Try this out

Thanks @Yoichi and @Sudharsan_Ka and also here i want to extract the second dynamic number which is 18,000.00 is that possible?

Hi,

Can you check the following pattern?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Invoice Amount [\d.,]+ )[\d.,]+").Value

or it might work if we use Matches activity with the pattern : "[\d.,]+"
It returns multiple matches.

Regards,

2 Likes

Thanks @Yoichi it works

1 Like

Hi anyone in the below text i want to extract the amount after Total which is 24,104.00 and 2,89,246 but when i try with a sample it matches with another “Total” in the below. can anyone tell how to use regex to extract both the amount after total dynamically.

Total 24,104.00 2,89,246.00
CONTRIBUTIONS
Total 1,800.00 30,754.00
Grand Total (CTC) 3,20,000.0

Hi,

Hope the following helps you.

System.Text.RegularExpressions.Regex.Matches(yourString,"(?<=Total )([\d,.]+)\s*([\d,.]+)")

Sequence1.xaml (6.8 KB)

Regards,

Thanks for the suggestion @Yoichi … But here its selecting both the amounts of total (24,104.00 2,89,246.00) but i want to use regex to extract the first number (24,104.00) separately and the second number (2,89,246.00) separately

Hi @padmapadh1895

You can try with group in regex

Group 1 will be the first value group 2 will the second value

Regards
Sudharsan

Hi,

Can you check output expression of the sample as the following.

item.Group(1).Value
item.Group(2).Value

Regards,

1 Like