Amount using regex

Hi, how to get the amount $12,123.56 from below using Regular Expressions? Can you help pl? Thank you.

Total Amount
Flight Charges
Hotel Expenses
$12,123.56
$687.123
$0.0

If you have any question, please email at

Try this:

$\d{1,3}(?:,?\d{3})*(?:.\d{2})?

Cheers! :slight_smile:

Hello

Try this pattern:
^\$[\d\,\.]+

Assign:
System.Text.RegularExpressions.Regex.Match(yourString,“^\$[\d\,\.]+”).ToString

image

Cheers

Steve

Hi,

If you want to extract value which appears first, the following works.

System.Text.RegularExpressions.Regex.Match(yourString,"\$[\d.,]+").Value

If you want to extract value which appears first after “Total Amount”, the following will work.

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Total Amount[\s\S]*?)\$[\d.,]+").Value

Regards,

Hi @A_Learner

You can use the data manipulation to extract the required output.

=> Assign -> StrVar = "Total Amount
                       Flight Charges
                       Hotel Expenses
                       $12,123.56
                       $687.123
                       $0.0"
=> Assign -> Output = StrVar.Split("$")(1).trim.toString

You can use the below regular expression to get the required output.

System.Text.RegularExpressions.Regex.Match(yourString,"^\$\d+\,\d+\.\d+").Value

image

Hope it helps!!

@A_Learner

System.Text.RegularExpressions.Regex.Match(yourString,"\$\d+\,\d+\.\d+").Value

Hello,
($\d{2},\d{3}.\d{2}) Try with this pattern
image

@A_Learner

If it is the first dollar value from the string then you can use split

Str.Split({"$"},StringSplitOptions.None)(1)

If you need after Hotel Expenses then use regex

System.Text.RegularExpressions.Regex.Match(str,"(?<=Hotel Expenses\r?\n).*").Value

Cheers