I have road ID labels in a string field that need to be parsed down. I'm using the python advanced label expression. I've removed the preceding '0s' successfully as well as some known text.

I need to remove all other preceding alpha characters prior (left of) to the number but keep any alpha characters after (right of) the number. The amount of characters vary so I can not use [:3] etc.

This code snippet removes ALL alpha, not just at beginning:

enter image description here

This snippet shows verified but does not yield any labels:

enter image description here

What is your syntax suggestion?

I've also tried lstrip()[0].isalpha() can't get that to work either.

1 Answer 1


A recursive solution might work. Something like:

def FindLabel(label):
    if label[0].isalpha():
    return label

Which would be called with FindLabel([ID])

  • I got the syntax correct by adding label = ( [ID] ) and it verifies but no labels are returned. def FindLabel ( [ID] ): label = ( [ID] ) if label[0].isalpha(): FindLabel([ID][1:]) Commented May 27, 2020 at 15:58
  • UPDATE: I've got the label syntax to work correctly but ONLY for the letter 'A' new syntax is: def FindLabel ( [ID] ): label = ( [ID] ) if label[0].isalpha(): return [ID].lstrip('A - Z') Commented May 27, 2020 at 16:11

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.