Functions and Available Formats
The following is an overview of the functions and their available formats.
String
| Function | Format | Description |
|---|---|---|
| compare | compare(str1,str2) |
Compare two strings lexicographically returning:
|
| compareIgnoreCase | compareIgnoreCase(str1,str2) | Compare two strings lexicographically, ignoring case differences. |
| concat | concat(str1,str2) | Concatenates str2 to the end of str1 and returns a new string. |
| contains | contains(str,search) | Checks if a string (str) contains a substring (search). |
| containsAny | containsAny(str,search1,search2,...) | Checks if a string (str) contains any of the substrings in the given array (search1,search2,...). |
| containsIgnoreCase | containsIgnoreCase(str,search) | Checks if a string (str) contains a substring (search) irrespective of case. |
| endsWith | endsWith(str,suffix) | Checks if a string (str) ends with a specified suffix. |
| endsWithIgnoreCase | endsWithIgnoreCase(str,suffix) | Case insensitive checks if a string (str) ends with a specified suffix. |
| indexOf | indexOf(str,search) | Finds the first index of a substring (search) within a string (str). Returns -1 if no match. |
| indexOfAny | indexOfAny(str,search1,search2,...) | Finds the first index of any of a set of substrings (search1,search2,...) within a string (str). Returns -1 if no match. |
| indexOfIgnoreCase | indexOfIgnoreCase(str,search) | Case insensitive find of the first index of a substring (search) within a string (str). Returns -1 if no match. |
| isAlpha | isAlpha(str) | Checks if the string contains only Unicode letters. |
| isBlank | isBlank(str) | Checks if a string is empty (""), null or whitespace only. |
| isEmpty | isEmpty(str) | Checks if a string is empty ("") or null. |
| isNumeric | isNumeric(str) | Checks if the string contains only Unicode digits. |
| isNumericSpace | isNumericSpace(str) | Checks if the string contains only Unicode digits or space (' '). |
| lowerCase | lowerCase(str) | Converts a string to lowercase. |
| upperCase | upperCase(str) | Converts a string to uppercase. |
| matches | matches(str,regex) | Checks if the str string matches the given regular expression. |
| left | left(str,len) | Gets the leftmost len characters of a string. If len characters are not available, or the string is null, the string will be returned without an exception. An empty string is returned if len is negative. |
| leftPad | leftPad(str,size) | Left pad a string with spaces (' '). The string is padded to the size of size. |
| leftPad | leftPad(str,size,padStr) | Left pad a string with a specified string (padStr). The string is padded to the size of size. |
| mid | mid(str,pos,len) | Gets len characters from the middle of a string. If len characters are not available, the remainder of the string will be returned without an exception. If the string is null, null will be returned. An empty string is returned if len is negative or exceeds the length of str. |
| right | right(str,len) | Gets the rightmost len characters of a string. If len characters are not available, or the string is null, the string will be returned without an exception. An empty string is returned if len is negative. |
| rightPad | rightPad(str,size) | Right pad a string with spaces (' '). The string is padded to the size of size. |
| rightPad | rightPad(str,size,padStr) | Right pad a string with a specified string (padStr). The string is padded to the size of size. |
| replace | replace(str,search,replacement) | Replaces all occurrences of search string within the str string with the given replacement. |
| replaceAll | replaceAll(str,regex,replacement) | Replaces each substring of the str string that matches the given regular expression with the given replacement. |
| replaceFirst | replaceFirst(str,regex,replacement) | Replaces the first substring of the str string that matches the given regular expression pattern with the given replacement. |
| startsWith | startsWith(str,prefix) | Checks if a string (str) starts with a specified prefix. |
| startsWithIgnoreCase | startsWithIgnoreCase(str,prefix) | Case insensitive checks if a string (str) starts with a specified prefix. |
| size | size(str) | Gets the length of a string. |
| strip | strip(str) | Strips whitespace from the start and end of a string. |
| substring | substring(str,start) | Gets a substring from the specified string. A negative start position can be used to start n characters from the end of the string. A null string will return null. An empty ("") string will return "". |
| substring | substring(str,start,end) | Gets a substring from the specified string. A negative start position can be used to start/end n characters from the end of the string. The returned substring starts with the character in the start position and ends before the end position. All position counting is zero-based (for example, to start at the beginning of the string use start = 0). Negative start and end positions can be used to specify offsets relative to the end of the string. If start is not strictly to the left of end, "" is returned. |
| truncate | truncate(str,maxlen) |
Truncates a string. This will turn "Now is the time for all good men" into "Now is the time for". Specifically:
|
| truncate | truncate(str,offset,maxlen) |
Truncates a string. Works like truncate(str,maxlen), but allows you to specify a "left edge" offset. Specifically:
|
| If-Then-Else | (condition ? true_expression : false_expression) | The condition is an expression that evaluates to a Boolean value, either true or false. If the condition is true, true_expression is returned, otherwise false_expression is returned. |
Numeric
| Function | Format | Description |
|---|---|---|
| abs | abs(num) | Returns the absolute value of a numeric value. |
| max | max(num1,num2) | Returns the greater of two numeric values. |
| min | min(num1,num2) | Returns the smaller of two numeric values. |
| ceil | ceil(num) | Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. |
| floor | floor(num) | Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. |
| log | log(num) | Returns the natural logarithm (base e) of a double value. |
| log10 | log10(num) | Returns the base 10 logarithm of a double value. |
| pow | pow(base,exponent) | Returns the value of the base argument raised to the power of the exponent argument. |
| round | round(num,places) | Round a number to N decimal places specified by the places argument. |
| sqrt | sqrt(num) | Returns the correctly rounded positive square root of a double value. |
| isNumber | isNumber(num) | Checks whether the given object is a number. |
| numberFormat | numberFormat(num,pattern) | Formats a number to produce a string with a given pattern. A pattern contains a positive and negative subpattern (for example, "#,##0.00;(#,##0.00)"). Each subpattern has a prefix, numeric part, and suffix. The negative subpattern is optional; if absent, then the positive subpattern prefixed with the localized minus sign ('-' in most locales) is used as the negative subpattern. |
| toDouble | toDouble(num) | Convert a string or number to a double, returning a default value if the conversion fails. |
| toInt | toInt(num) | Convert a string or number to an int, returning zero if the conversion fails. |
| toLong | toLong(num) | Convert a string or number to a long, returning zero if the conversion fails. |
| cos | cos(num) | Returns the trigonometric cosine of an angle. |
| sin | sin(num) | Returns the trigonometric sine of an angle. |
| tan | tan(num) | Returns the trigonometric tangent of an angle. |
| acos | acos(num) | Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. |
| asin | asin(num) | Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. |
| atan | atan(num) | Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. |
| cosh | cosh(num) | Returns the hyperbolic cosine of a double value. |
| sinh | sinh(num) | Returns the hyperbolic sine of a double value. |
| tanh | tanh(num) | Returns the hyperbolic tangent of a double value. |
Date
| Function | Format | Description |
|---|---|---|
| date | date(year,month,day) |
Returns a particular date defined by:
|
| date | date(year,month,day,hour,minute) |
Returns a particular date defined by:
|
| day | day(date) | Returns the day of month field of a date starting from 1 to 31. |
| edate | edate(date,months) | Returns the date before or after a specified number of months. |
| eomonth | eomonth(date,months) | Returns the last day of the month before or after a specified number of months. |
| hour | hour(date) | Returns the hour field of a date starting from 0 to 23. |
| minute | minute(date) | Returns the minute field of a date starting from 0 to 59. |
| month | month(date) | Returns the month field of a date starting from 1 to 12. |
| now | now() | Returns the current date and time. |
| today | today() | Returns today's date. |
| weekday | weekday(date) | Gets the day of the week from a given date. |
| weeknum | weeknum(date) | Gets the number from a given date representing where the week falls numerically with a year. |
| year | year(date) | Returns the year field of a date. |
| addDays | addDays(date,amount) | Adds a number of days to a date returning a new object. The original date is unchanged. |
| addHours | addHours(date,amount) | Adds a number of hours to a date returning a new object. The original date is unchanged. |
| addMinutes | addMinutes(date,amount) | Adds a number of minutes to a date returning a new object. The original date is unchanged. |
| addMonths | addMonths(date,amount) | Adds a number of months to a date returning a new object. The original date is unchanged. |
| addWeeks | addWeeks(date,amount) | Adds a number of weeks to a date returning a new object. The original date is unchanged. |
| addYears | addYears(date,amount) | Adds a number of years to a date returning a new object. The original date is unchanged. |
| dateDiff | dateDiff(start,end) | Returns the number of days between the start and end dates. |
| dateFormat | dateFormat(date,pattern) |
Formats a date to produce a string with a given pattern. For example:
|
| isSameDay | isSameDay(date1,date2) | Checks if two date objects are on the same day ignoring time. |
| toLong | toLong(date) | Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date. |
| toDate | toDate(long) | Returns a date object initialized to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. |