String functions
You can use string functions to manipulate string elements, typically field or element names.
The following table describes the string functions supported in rules files.
Function |
Description |
Example |
---|---|---|
|
Returns the number of characters in a string. Note: When using single byte characters, this will be the same
as the number returned by the
length() function.
When using multi-byte characters, this number can differ from that
returned by the length() function. |
|
|
Removes the elements of an array. |
|
|
TRUE if the expression contains the specified string. |
|
|
Returns the string (which must be a literal string) with escape sequences expanded. Possible expansions are:
This function cannot be used as the regular expression
argument in the Note: This function is deprecated and must not be used as the
regular expression argument in the
regmatch or extract functions.
Instead of using expand , contain the regular expression
in single quotes, for example:
|
sends the following to the log:
|
|
Returns the part of the string (which can be a field, element, or string expression) that matches the parenthesized section of the regular expression. In Fix Pack 4 or later, the regexp
parameter can be a string or a string expression. In previous releases only string literals could be
used for regular expressions.
Note: If
you provide an invalid string expression for the regexp parameter, it will fail
to compile, and the result of an
extract call will be a blank string. |
If |
|
Returns the number of bytes in a string. |
|
|
Converts an expression to lowercase. |
|
|
Removes white space from the left of an expression. |
|
|
TRUE if the expression value matches the string exactly. |
|
|
Returns an MD5 hash from a string. |
|
|
TRUE if the expression starts with the specified string. |
|
|
Creates or updates a name-value pair string of extended attributes. Multiple name-value pairs can be supplied for the string. Variables and their values can be added to, or replaced in, the name-value pair string. Creates a name-value pair string
of all variables and their values when called as |
If
$PercentFull is 97 and $Disk is /dev/sfa1, @ExtendedAttr will be (assuming
it was initially empty): |
|
Used with extended attributes. Removes specified keys from a name-value pair string, and returns the new name-value pair string. Useful where the list of extended attributes to
include is longer than the list of attributes to exclude. You can
use |
This results in @ExtendedAttr
being: |
|
Converts any non-printable characters in the given expression into a space character. |
|
|
Full regular expression matching. In Fix Pack 4 or later, the regexp parameter
can be a string or a string expression. Previous levels only allowed
the use of string literals for regular expressions.
Note: If you provide
an invalid string expression for the regexp parameter,
it will fail to compile, and the result of a
regmatch call
will be false. |
|
|
Uses a regular expression and a substitution string to perform a search and replace operation on an input string expression. In Fix Pack 4 or later, the regexp parameter
can be a string or a string expression. Previous levels only allowed
the use of string literals for regular expressions.
Note: If you provide
an invalid string expression for the regexp parameter,
it will fail to compile, and the result of a
regreplace call
becomes the original input string. |
|
|
Removes white space from the right of an expression. |
|
|
Converts the expression according to the following
formats, similar to the
|
This
sets |
|
Separates the specified string into elements of the destination array. The field separator separates the elements. The field separator itself is not returned. If you specify multiple characters in the field separator, when any combination of one or more of the characters is found in the string, a separation occurs. Regular expressions are not allowed in the string or field separator. You must define the |
Example 1. Example 1 creates an array with three entries. Leading/trailing delimiters are ignored and
multiple contiguous delimiters are treated as a single delimiter.
Example 2.
Use
example 2 if empty strings are needed, when leading, trailing, and contiguous delimiters count. Example 3.
When
you call split on a character that has a special meaning in regular expressions, such as
"|" , you must escape that character, per example 3. |
|
Extracts a substring, starting at the position specified in the second parameter, for the number of characters specified by the third parameter. |
extracts 10 characters from the second position of the |
|
Converts an expression to uppercase. |
|