Take the 2-minute tour ×

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

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

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


