Select to view content in your preferred language

Remove leading zeros from value

3686
6
11-15-2013 05:32 AM
TinaCanady
Deactivated User
Hi,
I would like to have the leading zeros removed from the output results.  For example when a feature is selected and the attributes are displayed I want it to show L-12345 not L-0000000012345.  Or if you do a search by typing in L-12345 and not     
L-0000000012345.  Is there a way to do this in the esearch widget tool?  Thanks!
Tags (2)
0 Kudos
6 Replies
RobertBorchert
Honored Contributor
Are all the fields similar in that the first character is a letter and the second is the  "-" symbol and the third is a Zero?




Hi,
I would like to have the leading zeros removed from the output results.  For example when a feature is selected and the attributes are displayed I want it to show L-12345 not L-0000000012345.  Or if you do a search by typing in L-12345 and not     
L-0000000012345.  Is there a way to do this in the esearch widget tool?  Thanks!
0 Kudos
TinaCanady
Deactivated User
Are all the fields similar in that the first character is a letter and the second is the  "-" symbol and the third is a Zero?


Yes that is correct.
0 Kudos
RobertBorchert
Honored Contributor
Go to the layer properties in your attribute with the leading zeros.

Click on the display tab and then the Expression button.

Where there is the check box for Advanced click that.

Now write this in your dialog box. or copy paste if it works

Function FindLabel ( [TextTest]  )
if instr(3, [TextTest] ,1)  then 
FindLabel = left( [TextTest] ,2) & mid( [TextTest] ,(instr(3,[TextTest] ,1)),10)
end if

End Function

Where it says [TextTest] change it to your attribute
Now this is important.  The way it is in now it will only do it correctly for the strings that start with a 1 after the zeros.

Copy and paste everything from and including IF to End IF

change both of the 1 to 2  paste again for each number through 9 and change the 1 to the next number.  make sure End Function stays at the end.

Where you see the 10 that is the number of characters after the zeros to display.  If your string is longer than that increase the number.
0 Kudos
TinaCanady
Deactivated User
Go to the layer properties in your attribute with the leading zeros.

Click on the display tab and then the Expression button.

Where there is the check box for Advanced click that.

Now write this in your dialog box. or copy paste if it works

Function FindLabel ( [TextTest]  )
if instr(3, [TextTest] ,1)  then 
FindLabel = left( [TextTest] ,2) & mid( [TextTest] ,(instr(3,[TextTest] ,1)),10)
end if

End Function

Where it says [TextTest] change it to your attribute
Now this is important.  The way it is in now it will only do it correctly for the strings that start with a 1 after the zeros.

Copy and paste everything from and including IF to End IF

change both of the 1 to 2  paste again for each number through 9 and change the 1 to the next number.  make sure End Function stays at the end.

Where you see the 10 that is the number of characters after the zeros to display.  If your string is longer than that increase the number.


Thank you so much, I will give it a try and let you know what happens!
Tina
0 Kudos
RobertBorchert
Honored Contributor
TRY JUST the first part first to make sure it is working for you before creating the rest of the code.
0 Kudos
TinaCanady
Deactivated User
TRY JUST the first part first to make sure it is working for you before creating the rest of the code.


It worked!
Thanks again
Tina
0 Kudos