HOW TO

Remove specific characters from a string field using Arcade in ArcGIS Online

First Published: May 25, 2023
Last Published: May 11, 2026

Summary

Removing specific characters from a string field can be useful for data management, and in ArcGIS Online, it is possible to remove them using an Arcade expression. The replace() Text function in ArcGIS Arcade is used to remove these leading or trailing characters.

The Company field containing trailing characters, as shown in the attribute table below, is used to demonstrate the workflow in this article.

String field with specific trailing text characters.

Procedure

  1. In ArcGIS Online, click the desired hosted feature layer. On the item page, click the Data tab.
Note: 
Skip to Step 3 if the script is run on an existing field.
  1. In the Table view, create a new field. Refer to ArcGIS Online: Add a field for instructions. In this example, the CompanyNew field is created.
Note:
Ensure to select the String data type when creating the new field.
  1. Click Menu on the header of the new field and select Calculate. In this example, CompanyNew is selected.
  2. For Field, click the drop-down menu to select the field. In this example, CompanyNew is selected.
  3. For Select language, select Arcade.
  4. Click Next.
  5. Specify the Arcade expression field as follows:
Replace($feature.<field_name>, "<text_value>", " ")
  1. Replace <field_name> with the name of the field from which the characters are to be removed. In this example, Company is used.
  2. Replace <text_value> with the value of the specific characters to be removed. Here, '-#' is used, and in the Arcade expression, " " is added as the value to replace '-#' as it represents an empty text value. If there are multiple, separate characters to be removed, run the replace() function multiple times, as in the following expression:
Replace(Replace($feature.<field_name>, "<text_value1>"," "),"<text_value2>"," ")
  1. Click Run to verify the expression, and click Run calculation to apply the query.
Expression to remove specific trailing characters in Arcade Calculator dialog box.

The table below demonstrates the CompanyNew field populated by values from the Company field with the trailing characters removed.

String field without specific trailing characters.

Article ID: 000030333

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options