Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to use the Python field calculator to remove the hyphen from a field column. For example, I would like to parse out the hyphen from an entry like "123-45-6789" and read "123456789".

share|improve this question
Why the down votes? – Nathan W Dec 26 '12 at 2:28

2 Answers 2

The sub method in Python's regular expression module should do the trick.

import re
no_hyphens = re.sub('-','','123-45-6789')

This will replace any instance of a "-" with an empty string.

share|improve this answer

Use the built-in str.replace method accessible on all string objects.

Make sure Python is checked in the Parser at the top

Put this in the Expression box (replacing "FieldName" with your own):

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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