String Functions
Introduction
When retrieving a value from a variable using @GET or in an inline
variable, you can perform string operations on the contents. These are
specified by chaining together string actions using colons after the variable
name or using FORMAT in @GET.
For example, to retrieve uppercase version of the third field in a record
separated by slashes:
<@GET NAME="RECORD:WORD(3,/):UPCASE()">
Manipulation
UPCASE()
Returns the contents of the variable in uppercase
DOWNCASE()
Returns the contents of the variable in lowercase
ESCAPEURL()
Replaces spaces with plus signs and URL-escapes all HTTP-significant
characters
UNESCAPEURL()
The reverse of ESCAPEURL
ESCAPECHARS()
Returns the contents of the variable with HTML-significant characters replaced
by their entities
UNESCAPECHARS()
The reverse of ESCAPECHARS
REVERSE()
Returns the characters in the variable in reverse order
REPLACE(string,string)
Replaces all occurences of the first string with the second
REPEAT(expr)
Repeats the contents of the variable the specified number of times
C2X()
Converts a sequence of characters to a sequence of hexadecimal pairs of the
ASCII values
D2X()
Converts a decimal number to a hexadecimal number
ROMAN()
Converts an integer to a roman numeral
RANDOM()
Returns a random number between zero and one less than the value passed
Substring Extraction
BEFORE(string)
Returns the part of the variable before the first occurence of the specified
string
AFTER(string)
Returns the part of the variable after the first occurence of the specified
string
LEFT(expr)
Returns the number of characters specified from the left of the variable. A
negative value will specify the number of characters to miss from the
right.
RIGHT(expr)
Returns the number of characters specified from the right of the variable. A
negative value will specify the number of characters to miss from the left.
MID(expr,expr)
Returns the number of characters specified by the second expression from the
position specified by the first. If the first is negative the start position
is measured from the end of the string
REMOVENOTOF(string)
Returns the contents of the variable with every occurence of every character
not in the string removed
PADLEFT(expr,string)
Returns the contents of the variable padded on the left with repetitions of
the contents of string until it is at least as long as the value given by the
expression. If string is not specified, spaces are used
PADRIGHT(expr,string)
As PADLEFT, but on the right side
Date Handling
DATETODAYNUM()
Returns the day number of a date supplied in YYYY-MM-DD format so it can be
used in mathematical expressions
DAYNUMTODATE()
Converts a day number to a date in the format YYYY-MM-DD
DAYOFWEEK()
Returns the day of week value for a date in the format YYYY-MM-DD with
Monday=1, Sunday=7
Enquiry
LENGTH()
Returns the number of characters in the variable
FREQ(string)
Returns the number of times the string occurs in the variable
Word Extraction
WORD(expr)(expr,string)
Returns the word at the specified position. If the expression is negative the
position is counted from the right. The word separator is a space unless a
string is specified
WORDS()(string)
Returns the number of words in the variable. The word separator is a space
unless a string is specified
WORDSPAN(expr,expr)(expr,expr,string)
Returns the words indexed from the first expression to the second expression.
If either expression is negative the position is counted from the right. The
word separator is a space unless a string is specified
Maths
EVAL()
Evaluates the contents of the variable as a mathematical expression
|