XpressDox has numerous string handling functions. The number of different applications is vast, and this article tries to provide a number of situations all in one place.
Extract the last few characters of a string
Suppose you have a situation where a particular data element will always contain a specific code in the last 3 characters, but in general the data element can have any number of characters in it. To extract the last 3 characters, a combination of substring and string-length is used:
The last three characters of the account number are
Extract the initials from the first names
Not much needs to be said here, because the ExtractInitials function was invented for just that. Here is an example, with a bonus showing how various name-handling features of XpressDox come together:
«If(GreetingType = 'Informal' and FirstNames != '')»«substring-before(concat(FirstNames,' '),' ')»«Else()»«Title»
Notice the concat inside the substring-before: this is to make sure that if there is only one FirstNames specified, then there will still be space after it. When more than one name is in FirstNames, the extra space added by the concat won’t make any difference to to execution of substring-before.
Another way of getting the first of the names, even when there is only one (and there is no trailing space inside the FirstNames data element), is: