Hi,
I have labels that contain letters,symbols and numbers : (12/34-5) Name
I would like to remove (12/34-5) and leave Name only
Any suggestions?
Hi Mar,
You can use a label expression. Go to label tab in layer properties and select label expression. use below label expression to create your label (please be mindful of line intend)
import re def FindLabel ( [CODETEMPS] ): p = re.search('(?=\()(.*?)(?=\))', [CODETEMPS]) if p is None: return [CODETEMPS] else: return p.group(0).replace('(','')
Below screenshot of label created using above expression.
Thank you very much
There are Names with 2 words so they have space in it.
I was thinking more like this:
replace ) with ""
split at )
but I need code
Hey - best would be to see all the versions of texts in your data. And I assume it is about ArcGIS for Desktop-Labeling? Your solution would look something like this: Take the whole String and filter out the crap. Would be easiest if all Names are in brackets - assuming they are not, try this as a python Advanced labeling expression - changing the [fieldname] in the brackets with your real fieldname:
def FindLabel([theName]):
#get the text in the field
txt = [theName]
# if txt has a blank in it (which means it has the date), get rid of it
if " " in txt:
txt=txt.split(' ')[1]
#now do the same with the leading bracket - non-existance is no problem this way
if "(" in txt:
txt=txt.split('(')[1]
#and the ending bracket - non-existance is no problem this way
if ")" in txt:
txt=txt.split(')')[0]
return txt
Sorry my mistake,
format is 123/45-67 (Name) and not all have that format.
Some of them are just Name without numbers
So I have to lose numbers and brackets
I've moved your post into the Managing Data space. You will get a much better answer here as the GeoNet Help is intended for community help and feedback. You can see more on the community structure, and what topics are under each space from the following documents:
GeoNet Community Structure
ArcGIS Discussion Forums Migration Strategy
Thanks!
Timothy
If you are using the filed calculator and if your numbers are always the same length (in this case 10 characters (including the space before the Name)), you could use:
Right([Field],length([Field])-10)
or you could split the field on the space and grab the second part:
Split([Field], " ")(1)
If you would prefer to use python as the parser then there is a good example here:
Field Calculator: I just want the third word | SoCalGIS.org
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.