Julie,
As it sounds like you potentially could have hundreds or thousands of keys to check for in the string. I would not recommend doing this dynamically in the Popup. The main reason is Arcade does not currently include the ability to reference external tables or data and is only limited to the current data contained in the feature class or generated expressions. Second it could be very slow.
I would recommend adding an additional text field to your feature class and pre-generating the display HTML and storing it in the feature class. This can easily be generated using python from a script tool from the text string that is stored in the feature class. You will also need a key index to hold the strings to be replaced and their equal HTML url. This could be stored in a small dictionary in the code for a limited number of keys or a data table for unlimited number of keys.
The table will contain two fields: 1) key text string to look for and 2) the URL
The second part needed is the script to take a string, wrap it as HTML and replace the keys found with the keyHTML and save it to the feature class attribute. I prefer Python to do this and you would be iterating thought the list of keys, checking for a match and replacing if found. This process would not scale well for a very large number of key values and would need to be modified. Since this would be preprocessed, the user would not be encumbered with the processing time. Below is a sample Python script using a dictionary for the key values.
keys = {}
keys['Development Activities'] = 'http://development.com'
keys['Parks Art'] = 'http://parks_art.org'
keys['Lorem ipsum'] = 'http://Lorem_ipsum.net'
keys['Eam at officiis'] = 'https://eam.org/officiis'
keys['suscipit'] = 'https://eam.org/suscipit'
keys['Test'] = 'http://test.org/test'
def replaceKeys(str):
print str
for key in keys:
if key in str:
href = '<a href="%s">%s</a>' %(keys[key], key)
str = str.replace(key, href)
return '<p>%s</p>' %(str)
def main():
str = 'Development Activities are prohibited as per the Parks Art.'
print replaceKeys(str)
str = 'Lorem ipsum dolor sit amet, eam et quas atqui delicata. Eam at officiis reformidans. Mei ne quando suscipit definitionem, per et tota summo minimum.'
print replaceKeys(str)
str = 'Test to see if this case sensitive. This is just a test.'
print replaceKeys(str)
The above outputs:
Development Activities are prohibited as per the Parks Art.
Development Activities are prohibited as per the Parks Art.
Lorem ipsum dolor sit amet, eam et quas atqui delicata. Eam at officiis reformidans. Mei ne quando suscipit definitionem, per et tota summo minimum.
Lorem ipsum dolor sit amet, eam et quas atqui delicata. Eam at officiis reformidans. Mei ne quando suscipit definitionem, per et tota summo minimum.
Test to see if this case sensitive. This is just a test.
Test to see if this case sensitive. This is just a test. (Note, only the capitalized "Test" was replaced)
Rather than printing you would be writing these to your feature class HTML Attribute as you iterate through the data using a cursor. You can also change line 16 to str = str.replace(key, href, 1). This will then only replace the first occurrence of the key found for each string
In AGOL you can use the pre-generated keyHTML field in the pop-up configuration adding each for Goal, Objective and Note as well as additional static text. and noted in the previous references. Sorry for the clunky example but without seeing your actual data or how you are implementing this I had to get a little creative.