Extract digit from Negative balance

Hi ,

I need to extract only 1,144,000 from negative balance “1,144,000-”

use regex

System.text.regularexpression.regex.match(yourstring,"[\d,]+").value

1 Like

Hi @shruthi_arali

You can use the following RegEx pattern:

-?([0-9,]+)

image

UiPath Syntax:

extractedData = System.Text.RegularExpressions.Regex.Match(yourString,"-?([0-9,]+)").ToString

Hope this helps,
Best Regards.

Hi @shruthi_arali

How about this expression?

System.Text.RegularExpressions.Regex.Match(yourString,"[.,0-9]+").ToString

Or

System.Text.RegularExpressions.Regex.Match(yourString,"[.,0-9]+(?=-)").ToString

image

Regards
Gokul

HI @shruthi_arali

You can also use replace method here
Note: only if you have the “1,144,000-” this as your full input like

InputData = “1,144,000-”

InputData.Replace("-","")

or

System.Text.RegularExpressions.Regex.Replace(InputData,"-","").ToString

Regards
Sudharsan

1 Like

we do handle the format and ending minus sign with parsing using the culture
taking the non negative value we can use the Abs (Absolute) from Math

Math.Abs(Double.Parse(strYourValue, NumberStyles.Any ,System.Globalization.CultureInfo.CreateSpecificCulture("en-ES")))