Text Parameters Modifiers
You can use modifiers to modify values of the text parameters.
Syntax
The syntax for using modifiers is as follows:
%<mod1|mod2|...|modN>ParameterName%
When multiple modifiers are supplied they are applied sequentially in the order they appear in the list.
Some modifiers accept one or more arguments. The syntax for a modifier with arguments is:
modifier(argument1,argument2...)
When an argument contains special characters, you will need to use appropriate codes. The codes for special characters are as follows:
- &cm; - Comma ( , )
- &lp; - Left parenthesis ( ( )
- &rp; - Right parenthesis ( ) )
- &vb; - Vertical bar ( | )
- < - Less than ( < )
- > - Greater than ( > )
- &am; - Ampersand ( & )
Modifiers
- adj - Adjusts the text by converting each white space sequence (space, tab, line feed, etc.) into a single space character and removing spaces from the beginning and from the end of the text.
- adjlb - Same as adj, but preserves line breaks.
- sql - Duplicates each single quote ( ' ) character found in the text, making it safe for using in SQL queries (for example, converts Hello 'Mike' into Hello ''Mike'').
- vbs - Modifies the text in a way to be safe for passing it to a Visual Basic script. This modifier removes all double quote characters ( " ) from the text and makes sure that no more than one slash character ( / )
appears at the beginning of the text.
- xml - Modifies the text to conform with the XML syntax for special characters (for example, converts Hello 'Mike' into Hello 'Mike').
- substr(start,length) - Returns a substring of the text which starts at the position specified with the start argument of the maximum length specified with the length argument. If start is
negative, the starting position is that many characters from the end of the string. If length is negative, then that many characters are removed from the end of the resulting string. The length argument may be omitted,
in which case all characters from the starting position to the end of the string will be returned.
- replace(charset,string) - Replaces each occurrence of any character from the charset found in the text with the supplied string.
- left(charset) - Returns the left part of the text which precedes the first occurrence of any character from the charset.
- right(charset) - Returns the right part of the text which follows the first occurrence of any character from the charset.
- extract(charset,index) - Splits the text using characters specified in the charset as boundaries and returns the extracted part of the text specified with the index argument. If index is
positive, the parts are numbered from the left. If index is negative, then the parts are numbered from the right. The default value for
index if omitted is 1. If there is no part specified with index, or index has a value of 0, then the empty string is returned.
- url, to_url - Converts text to URL encoded string (for example, converts Hello Mike into Hello%20Mike).
- from_url - Converts text from URL encoded string..
- ahex, to_ahex - Converts text to hex encoded string (for example, converts abc to 616263).
- from_ahex - Converts text from hex encoded string (for
example, converts 616263 to abc).
- uhexl, to_uhexl - Converts text to Unicode and then to hex encoded string using little-endian byte order (for example, converts abc to 610062006300).
- from_uhexl - Converts text from hex encoded
Unicode string using little-endian byte order (for example, converts 610062006300 to abc).
- uhexb, to_uhexb - Converts text to Unicode and then to hex encoded string using big-endian byte order (for example, converts abc to 006100620063).
- from_uhexb - Converts text from hex encoded Unicode string
using big-endian byte order (for example, converts 006100620063 to abc).
- utf8, to_utf8 - Converts text to UTF-8 encoded
string.
- from_utf8 - Converts text from UTF-8 encoded string.
- utf7, to_utf7 - Converts text to UTF-7 encoded
string.
- from_utf7 - Converts text from UTF-7 encoded string.
- crc16 - Calculates the CRC-16 value of the given array of bytes specified in the text with hex digits (for example, converts 2E053FA6
to A388).
- crc32 - Calculates the CRC-32 value of the given array of bytes specified in the text with hex digits.
- md5 - Calculates the MD5 value of the given array of bytes specified in the text with hex digits.
Examples
- %<sql|url>MsgText% - returns the value of the %MsgText% parameter with duplicated apostrophe characters and then converted to URL encoded string. This will convert Hello 'Mike' into
Hello%20%27%27Mike%27%27.
- %<from_utf8|to_url>MsgText% - returns the value of the
%MsgText% parameter converted from UTF-8 to URL encoded string.
- %<substr(5,3)>MsgText% - returns the substring of 3 characters starting at the 5th character of the value of the %MsgText% parameter.
- %<extract(&vb;,1)>MsgFrom% and %<extract(&vb;,2)>MsgFrom% - return the specified extracted parts of the value of the %MsgFrom% parameter after it was split with the vertical bar ( | ).
If the value of the %MsgFrom% parameter is short_code|billing_id, return values will be short_code and billing_id,
respectively.
- %<replace(0123456789,X)>MsgFrom% - returns the value of the %MsgFrom% parameter where all digits are replaced with X.
- %<right(+)>MsgFrom% - returns the string that follows the first occurrence of the plus character ( + ) found in the value of the %MsgFrom% parameter. This can be useful for removing the leading plus character from
the phone number.
- %<ahex|md5>MsgText% - returns the MD5 value of the text contained in the %MsgText% parameter.