13.7. Text Functions

The following text functions are available for use in formulas in Cartographica. To use them, they must always be "attached" to a string object, as they are string object methods, as opposed to pure functions. Therefore, if you have a string column named my_value, you must use my_value.upper() to convert this to upper case. The length function, len(my_value), is a generic function and thus still must surround the string variable.

Also note that strings use collection operators as well, so if you want the first 2 characters of a string, you may retrieve them by using my_value[0:2]; similarly, the 3rd and 4th characters may be retrieved by using my_value[2:4]. In addition, negative numbers connote references from the end of the string, so my_value[-2:] would retrieve the last 2 characters at the end of the string (the lack of a number after the colon connotes until the end).

[Note]1.5 Change

For those who have used Text functions in the past, there was a change in version 1.5 and beyond because of the adoption of a new Python 3-based back-end. In Cartographica 1.5 and beyond, Text functions are object methods and not pure functions. This means that if you previously used upper(my_value) to convert my_value to uppercase, then you now must use my_value.upper(). Cartographica will present an error or warning if this change affects existing formulas.