28.6.5 Specifying substrings in expressions
You can determine the number of characters in a macro variable, and use string operators to extract substrings from the value of the variable. Table 28-7 lists several of the string operators and shows how they are used in macro expressions.
§28.6.2 Understanding operands and operators
Table 28-4 Operators for HTML macro expressions
Table 28-7 String operators in macro expressions
For example, to trim off the first four characters of $$mystring:
<$$mystring = ($$yourstring trim first 4)>
If the value of $$yourstring is “makework”, the value of $$mystring would be “work”.
Implied value of second operand
If the second operand N is missing from an expression that uses one of the following operators, a value of 1 (one) is assumed for N:
For example, to select only the last character, you can omit the second operand:
<$$yourstring = ($$mystring last)>
If the value of $$mystring is “groceries”, the value of $$yourstring would be “s”.
> 28 Working with macros > 28.6 Using expressions in macros > 28.6.5 Specifying substrings in expressions