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?

3 Answers 3


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.


First, the resource page to help you in the future: Building label expressions

There are a lot of examples on that page, including Python, VBScript and JScript.

If it were me, building the expression in VBScript, I would use a combination of the Instr, Len, and Mid functions. If it is supported, use the InStrRev function, as that would let you search for the first instance of a "-" starting from the right.

You want to find the position of the "-" in the string, then count from there to the end of the string.

The definition of the Mid function is (Input String, Start Position, Number of Characters)


You just build your label function around this. Adding 1 to the Instrrev moves you to the character beyond the "-".

The bottom of that help document has links to string references for Python and VBScript. They are both exceedingly helpful for remembering these sorts of operations. I would look at Python as it can probably accomplish this same activity with a much smaller function length.



def FindLabel ( [name_field] ):
 return a

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.