Arcade needs a LIKE function

810
2
10-11-2021 10:29 AM
Status: Open
AmyRoust
Occasional Contributor III

I've had several use cases while using a when() or iif() function in Arcade where it would have been really nice to have the ability to match text using LIKE in the same way that it's used in SQL. My most recent use case is that I have several point locations on a map with a field holding website URLs. My client wants all URLs with a specific domain name (let's say www.esri.com as an example) to have different text for the hyperlink than all of the other URLs. So, I'd want to write a statement like this:

when($feature.URL LIKE "https://www.esri.com%", "Go to Esri sponsored site", "Vendor Website")

Any website that starts with https://www.esri.com would return the text "Go to Esri sponsored site" and all other sites would return Vendor Website. I can use that custom expression for the text:

AmyRoust_0-1633973291492.png

And use the {URL} parameter for the actual link.

2 Comments
KristianEkenes

I think Find should suit this case. Let me know if it doesn't...

 

IIF(Find("https://www.esri.com", $feature.URL) > -1, "Go to Esri sponsored site", "Vendor Website")

 

Here's the documentation: https://developers.arcgis.com/arcade/function-reference/text_functions/#find

 

AmyRoust

Oh nice! That worked like a charm. Thank you, Kristian!