Hello, I need to remove all html elements in text fields from popups in ArcGIS Pro/ArcGIS Enterprise. Text fields could contain multiple instances of <>.
text field - Description
<p><span style="color: rgb(68, 68, 68);">this artwork was commissioned through the City's </span>Hogan Alley Artist Call 2019. <span style="color: rgb(68, 68, 68);">In February 2019, the City invited proposals for a temporary painted mural. </span></p>
Can't find a way to set this up with Arcade
Thanks,
OM
Solved! Go to Solution.
It's not terribly elegant, but you can do this with a few nested loops and some splitting and searching.
var str = your-string-attribute
// Split input string by '>' char
var splits = Split(str, '>', -1, True)
// Empty string for output
var outstr = ''
// Iterate over split string
for (var s in splits){
var substr = splits[s]
// Find items not beginning w/ '<', i.e., not HTML tags
if (Left(substr, 1) != '<'){
// Check if string ends w/ HTML tag
var i = Find('<', substr)
// Trim HTML tag from end if present
if (i != -1){
substr = Left(substr, i)
}
outstr += substr
}
}
outstr
And for the proof:
You'll notice the " " does not get removed, but we were only looking for HTML tags. These could easily be stripped out with a Replace function, though. Or rather than stripping them out, replacing them with '\n'.
It's not terribly elegant, but you can do this with a few nested loops and some splitting and searching.
var str = your-string-attribute
// Split input string by '>' char
var splits = Split(str, '>', -1, True)
// Empty string for output
var outstr = ''
// Iterate over split string
for (var s in splits){
var substr = splits[s]
// Find items not beginning w/ '<', i.e., not HTML tags
if (Left(substr, 1) != '<'){
// Check if string ends w/ HTML tag
var i = Find('<', substr)
// Trim HTML tag from end if present
if (i != -1){
substr = Left(substr, i)
}
outstr += substr
}
}
outstr
And for the proof:
You'll notice the " " does not get removed, but we were only looking for HTML tags. These could easily be stripped out with a Replace function, though. Or rather than stripping them out, replacing them with '\n'.
Can't thank you enough for solving this. It worked great.
Olga