How could I ignore the last leading zero

Hey guys

How could I ignore the last leading zero?

there are cases that will have 0 to the left and cases that do not

my value is this

image

I wanted it to be: 330.007

without the last leading zero.

I tried with the expression

variable(0).value.replace(“0”, "")

but it eliminates all “0”

image

Just for information, this found value is extracted from a pdf.

so, in my case, the variable will be = variable (0) .value

1 Like

Hi

Hope this expression would help you resolve this

Use a assign activity like this

If input stored in a string variable named str_input

Then

str_output = IF(String.IsNullorEmpty(str_input.ToString) OR str_input.ToString.Equals(“0”),string.Empty,Convert.ToDouble(str_input.ToString.Trim).ToString.TrimStart(“0”c).ToString)

Where str_output is a variable of type string

This will first check whether the input is zero or has no value in it.

If it has no value or it’s zero then it will give empty value to the output variable str_output

Or

It will convert the string to double first which will remove right side zeros and trimstart will remove left side zeroes

Cheers @Guilherme_Silva

1 Like

Thanks for the answer.

I gave your advice, but it only came back as “false”, can you check?

please

highlight just wanted the last 0 to be deleted.

but there will be times when that last leading zero may not exist.

but I should just delete the one on the left, if it’s the last one

if by chance it doesn’t contain the leading zero, you can just ignore it

Main.xaml (6.0 KB)
pdf.txt (94 Bytes)

How about this…

image

If first one is showing an error, you can import system.globalization OR Use the second code…Make sure output is double value. If you want it in string just use .tostring at the end…

image

Hope this helps…

Thank you very much!!

Thanks to everyone who tried to help me

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