Labelling : abbreviate part of composite names like Saint-Jacques

546
5
02-13-2022 09:48 AM
Status: Open
Labels (1)
GregoireS
Occasional Contributor

In french, a street name Saint-Jacques would be abbreviated "St-Jacques".

As "Saint" is only a part of the word, putting Saint > St in the dictionary  doesn't abbreviate it.

And since there is a lot of saints, i don't want to add all of them in my abbreviation dictionary.

It would be nice to be able to work with the "Saint" part only, with something like "Saint%" or "Saint-%" in the dictionary.

Tags (1)
5 Comments
jcarlson

More support for regex in general would be great!

WendyHarrison

One option would be to use Alternate expressions.

You can find an example used just after the 38 min mark of the UC2021 Advanced Labeling presentation

https://www.esri.com/training/catalog/6165ae8d28674c33845f6fb5/arcgis-pro%3A-advanced-map-labeling/

GregoireS

Thanks @WendyHarrison  for your answer.

If i understand well, i would need to either value a new field with the special values, or write an arcade code for it.

If that's correct, well this is definitely one level above what i'm suggesting.  The "new field" solution seems inappropriate for that case, as it would be used only for 1 expression. And for the Arcade solution, if i could easily write arcade code, it would probably be a solution, even if it's dealing exceptions with another tool, which is not that clean in my perspective. 

And also i don't know if the alternate expression will only get active to avoid overriding/removing or every time.

So i think the solution i propose is more appropriated for common users. 

WendyHarrison

@GregoireS 

The alternate expression will only abbreviate the word if it is needed to fit the label.  

see the image below where the Replace function will swap out Saint- for St- 

return Replace($feature.notes, "Saint-", "St-")

WendyHarrison_0-1645656969243.png

 

 

GregoireS

OK thanks for that precision and the code