HOW TO

Remove and replace characters from a field in an attribute table in ArcGIS Pro

Last Published: July 18, 2023

Summary

The instructions provided describe how to remove and replace characters from a field in an attribute table using the Calculate Field tool in ArcGIS Pro. In this example, the hyphens (-) are removed under the Region field of the attribute table, and replaced with a comma (,) for improved readability.

An attribute table with hyphens in the Region field

Procedure

  1. Open the project in ArcGIS Pro.
  2. Right-click the layer in the Contents pane, and click Attribute Table.
  3. Click the Calculate Field button The Calculate Field button to open the Calculate Field geoprocessing tool.
  4. In the Calculate Field pane, select the field for editing under Field Name (Existing or New). In this example, it is Region. Ensure the Expression Type is Python3.
  5. Under the Expression section, click the field for editing (in this example, it is Region) from the Fields list. Click .replace() from the Helpers list.
  6. Within the bracket in .replace(), type "-","," to replace the hyphens with a comma, as shown below.
 ![FieldName]!.replace("-",", ")

The following demonstrates the proper expression:

 !Region!.replace("-",", ")
  1. Click OK. The tool completes with the hyphens removed and replaced with a comma.
The Calculate Field tool window is to be configured.
  1. Click the Save Edits button The Save Edits button in the Calculate Field pane to save the changes.
The attribute table with the hyphens replaced with commas

Article ID:000022616

Software:
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options