I have field called PIN in my parcels shapefile. Formatting looks like this: xx-yy-zzzzz, just much longer. I want to split the first two sections on one line and the third (the z's) on the next. I figured I could do this with an expression in 'Label Expression', but do not know how to parse every record in a field.

So basically I want this to do something like this:

PIN[:5] + "\n" + PIN[6:]

What is the correct syntax?


I'm assuming you're having trouble with varying length of strings between hyphens and that your record is in the format xx-yy-zzzz, i.e. always two hyphens.

You can use advanced labeling ticking the advanced checkbox and choosing parser: python. A simple method is to use string.split which returns a list of the substrings between the split char:

def FindLabel([PIN]):
    Values = [PIN].split('-')

Where \n is the newline character for a label.

  • Thank you, this is not exactly what I was trying to do (I should have provided the actual PIN), but it was a enough to steer me in the right direction. Here's what I came up with: def FindLabel([PIN]): values = [PIN][:15] + "\n" + [PIN][16:] return values – Mwspencer Aug 18 '17 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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