HOW TO

Replace multiple text in a single string using Arcade in ArcGIS Online Map Viewer

Last Published: December 6, 2023

Summary

In ArcGIS Online Map Viewer, descriptive details of features within a map are displayed through pop-ups. Pop-ups can display attachments, charts, images, texts, and links to external web pages. In some cases, the pop-up display includes special character strings in each field and these characters must be replaced. The task of replacing these fields is simpler with Arcade expressions.

This article provides instructions to replace multiple text or special characters in a single string using Arcade expressions in ArcGIS Online Map Viewer.

Procedure

  1. Open the map in Map Viewer. Click Layers, and select the <layer name> with the pop-up for editing.
The Map Viewer Contents toolbar with the Layers tab
  1. Click Configure pop-ups > Manage expressions.
The Map Viewer Pop-ups pane used to navigate to the Map Viewer Pop-up expressions pane
  1. Click + Add expression to open the Arcade Expression dialog box.
The Map Viewer Pop-up expressions pane with the Add expression icon
  1. Configure the Arcade expression using the variables assigned with the Replace() function to identify the multiple text or characters, and replace them with the desired text in the field. The sample Arcade expression below replaces the special characters or symbols in the Notes field of the feature layer.
var str=Replace($feature.Notes, '&', 'and') //Replace & to spell and
var str1=Replace(str, '#', 'No.') // Replace # with the word No. 
var str2=Replace(str1, '\ ', ' ') // Replace \ with a blank space
Replace(str2, '/', ' ') // Final replacement to return the result
  1. Rename the expression. In this example, the expression is named Notes to match the selected field name. Click OK.
The Map Viewer Arcade expression dialog box to define expressions and rename the expression
  1. Click the previous button The previous arrow icon to return to the Pop-ups pane.
The Map Viewer Pop-up expressions pane with the newly added expression
  1. Click Fields list to expand the list of fields currently displayed in the pop-ups, and click Select fields.
The Map Viewer Pop-ups pane displaying the location of the Fields list section
  1. Uncheck the Notes field without the Arcade expression, and check the Notes field with the Arcade expression. Click Done.
The Map Viewer Select fields pane to select fields to be displayed in the pop-up

The image below shows the pop-up of the standard Notes field.

The Map Viewer pop-up without the Arcade expression for the Notes field

The image below shows the pop-up of the Notes field with the Arcade expression.

The Map Viewer pop-up with the Arcade expression for the Notes field

Article ID:000026849

Software:
  • ArcGIS Online

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