Regex - Only second monetary value

I need help witha regex code that extracts only the second monetary value, ignoring the first one, as in the example below:

Total de Notas Ativas R$ 135.188,49 R$ 4.506.281,41

I need only the second value.

thanks!

@aleemendes

(?<=\d+\sR\$\s+)[\d\.\,]+
System.Text.RegularExpressions.Regex.Match(InputText,"(?<=\d+\sR\$\s+)[\d\.\,]+").Value
1 Like

Hi @aleemendes

You can use the String Manipulations for this to get the second monetary value,

- Assign -> Input = "Total de Notas Ativas R$ 135.188,49 R$ 4.506.281,41"

- Assign -> Output = Input.Split("R$").last.toString.Trim

Check the below result for better understanding,

Or use the below regular expression to get the required output,

- Assign -> Input = "Total de Notas Ativas R$ 135.188,49 R$ 4.506.281,41"

- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.toString, "(?<=\R\$.*\R\$\s*)[\d,.]+").Value.toString.Trim

image

Hope it helps!!

Hi @aleemendes

Try this

System.Text.RegularExpressions.Regex.Matches(Input.ToString,"(?<=R\$\s+)[\d.,]+").Last.ToString

Regards,

Hie @aleemendes you can get the text using string manipulation method here the example hope it help you get your desired output mark this solution if you find it helps you
cheers happy automation

and here regex method to get the result

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