1

Is it possible to slice a string in ArcMap's HTML-like dynamic text elements?

I've got a string field "Code" with contents like 'A.3.5', I need to extract the number in the middle ('3' in this case). Preferably, counting both from the string's start and backwards from string's end (because some codes were loaded without the first or the last '.' between the middle number and the adjacent char).

The dynamic text element's statement is <dyn type="page" property="attribute" field="Code" domainlookup="true"/>. It's for a set of Data Driven Pages.

Python, VBScript or JScript solutions are welcome. I just don't know if they can be used within these text elements.

I'm asking specifically if this is possible, and how to do it if so. As a workaround, I've populated a new field in the SHP's dbf and used it in the text element.

Nevertheless, I'm being specific here because if it's possible to manipulate strings in these text elements I will need to do it many more times in the near future.

As good a workaround as the new field approach is, it's far from optimal. First, because I'm working with already field-dense shapefiles (many of them have around 200 fields, and more to be added over time). The example I provided is the simplest I could come up with, but there's a lot of to-be-extracted data crammed inside many other long string fields.

Furthermore, these shapefiles are destined for non GIS-savvy people who ideally ought to understand exactly what each field is. In time they should be populating / editing these fields by themselves, even create new fields. Which I'll have to teach them.

Adding unnecessary fields just as workarounds won't help in these cases. And eventualy it might lead to hitting a SHP's 255 fields limit.

  • Least cost solution - populate new field. – FelixIP Dec 22 '18 at 1:44
  • Thanks, it's not a bad idea. As a matter of fact, I'd already done it as a workaround to get the job done. HOwever, I've edited the question to expand upon the case and why I need to know if it's possible to manipulate strings from within text elements, especially dynamic text elements. – user99006 Dec 22 '18 at 18:56
  • You can 'label' something invisible and access text element from labeling script, e.g. gis.stackexchange.com/questions/124398/… – FelixIP Dec 22 '18 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.