[GIS] Using Python Parser of Label Expression to only show text after particular symbol

arcgis-desktoplabelingpython-parser

I have a bunch of point data that needs labeling. However the attribute used for labeling is more complex than is needed in the map.

Example of the attribute field for labeling:

  • 15/8-9a,
  • 001/15-2
  • 8/19-13

What we need to see labeled is any number and/or letter found after the "-" symbol.
So from the above example: 9a, 2, 13 will be displayed on the map.

I know this can be done with slicing but since the number of characters after "-" is variable I'm struggling a little with the expression.

I do not want to add a new field so am exploring writing a label expression.

Does anyone know what the expression might look like to handle this?

Best Answer

I would use a Python expression like the following by checking Advanced on the Label Expression dialog of the Labels tab of the Properties dialog:

def FindLabel ( [TestField] ):
  return [TestField].split("-")[1]

This relies on there only being one occurrence of "-" in the field.

Related Question