I've got a bunch of OpenStreetMap content that I'm trying to label (ArcGIS Pro 2.2.4) based on whether content is found in the other_tags field. Here's what I'm trying to do in the expression editor (Python):
def FindLabel ( [other_tags] ):
import re
ls = [other_tags]
slabel = re.search('"name:en"=>"(.*?)","', ls)
return slabel.group(1)
It says "NameError: name 'FindLabel' is not defined
Which is weird because if I remove the "," from the regex operation and do this:
def FindLabel ( [other_tags] ):
import re
ls = [other_tags]
slabel = re.search('"name:en"=>"(.*?)"', ls)
return slabel.group(1)
it renders as valid, although it prints out everything beyond the "name:en"=>" string.
I have also tried this, which validates but returns nothing:
def FindLabel ( [other_tags] ):
ss = [other_tags]
ls = ss[ss.find('"name:en"=>"')+1:ss.find('"')]
return ls
Here is a bit of the sort of substring someone could expect to find in OSM's other_tags:
"int_name"=>"Dubai","is_in:continent"=>"Asia","is_in:country_code"=>"AE","name:en"=>"Dubai","population"=>"1984000"....
Can anyone help me to get this label expression working?
Eric,
I was curious about this one and using ArcGIS Pro 2.3 I see the following:
seems to work?
2.3 will be available soon.
Mark
Mark, thanks for the reply - I went and typed it back in from scratch, and it worked - what can I say, regex is tricky sometimes, though my face is a bit red for submitting a question that ultimately was due to my own typo!!