Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

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.