Extract currency value using regular expressions

Need to extract currency value ex. have value SAR 0.00,SAR 1,456,254.00 like this and I want only values 0.00,1.456,524.00
Have tried with split functionality but getting error as " index out of box" initially the split is working as expected but after some time it is showing this message.
I am assigning the value as
stClosing_Bal= SAR 0.00 or stClosing_Bal= SAR 1,456,254.02
Output: stClosing_Bal= 0.00 or 1,456,254.02

Hello

I think I understand your sample…

Regex Pattern:

(?<=SAR\s)[\d,.]+

Take a look at this solution

Want to learn Regex? Check out my Mega post :blush:

Hi,
Can you try using this in Assign:
stClosing_Bal.Replace(“SAR”,“”).trim
Thanks.

Hi [Steven_McKeering],
Thanks for the reply.
Sorry that I forgot to say that SAR is not constant. The currency symbol can change
Ex: INR 0.00, USD 1,254,458.23

Hey @deepaksvg99

Okay, let’s try this pattern:

(?<=[A-Z]{3}\s)[\d,.]+

1 Like

@deepaksvg99 try out this
System.Text.RegularExpressions.Regex.Replace(Test, “[^0-9]”, “”)

Where Test in that expression will be ur variable name

Hi Steven,
Thank you very much for your support and the code

1 Like

Hi Nikhil,
Thank you for the code. It is working

Please mark it as solution
happy learning

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