Summary
The instructions provided describe how to remove numbers from a string field in an attribute table using the Field Calculator in ArcMap. In this example, Python code is used to remove the numbers in a string field without having to edit every record individually.
Procedure
To remove numbers from a string field in an attribute table:
- In ArcMap, click the Editor drop-down menu on the Editor toolbar, and select Start Editing.
- In the Table Of Contents, right-click the selected layer, and select Open Attribute Table.
- Right-click the field, and select Field Calculator.
- In the Field Calculator, select the Python parser, and check the Show Codeblock check box.
- In the Pre-Logic Script Code box, copy and paste the following code:
import re
def strip_digits(s):
return re.sub("\d+", "", s)
- Copy and paste the following code in the second box:
strip_digits(!Field_Name!)
- Replace !Field_Name! by double-clicking the field in the Fields list.
- Click OK, and the numbers are removed from the string field, as shown in the image below.
- In the Editor toolbar, select Stop Editing and Save Edits to keep the changes.