Q:

Removing first and third zeros of a fieldname in label expression

The fieldname only has three characters. I dont want to display zeros in the first and third values. example below.
010 = 1
100 = 10
01Y = 1Y
10Y = 10Y
I have figured out how to strip out zeros except for the second value.

A:

Use Python as the parser, and check the Advanced box. Then just replace yourFieldName with the name of the field you want to label.
def FindLabel([yourFieldName]):

    value = [yourFieldName]

    first = False
    third = False

    if value[0] == "0":
        first = True
    if value[2] == "0":
        third = True

    if first == True and third == False:
        return value[1:]

    elif first == False and third == True:
        return value[0:2]

    elif first == True and third == True:
        return value[1:2]

    else:
        return value

A:

For brevity's sake:
def FindLabel ([field]):
  val = [field]
  return ''.join([j for i, j in enumerate(val) if j != '0' or i == 1])

Step through the string and toss away all 0's unless it's in the middle position (index of 1), then join what's left.

A:

Here's a little more concise way of doing it. Basically convert it to a list and replace list[0] and list[2] with '' if the value is 0
def FindLabel([field]):
    value = [field]
    l_value = [x for x in value]    # turns string to list

    no_zero_positions = [0,2]       # where you don't want zeros
    for p in no_zero_positions:
        if l_value[p] == '0':
            l_value[p] = ''         # Replace zero with empty string

    return ''.join(l_value)        # list back to string

