Sun Identity Manager Deployment Reference

String Manipulation Expressions

Use the following functions to perform string manipulation within expressions.

indexOf Function

Returns the position of a string within another string.

Example

The following function returns 3.

<indexOf>
   <s>abcabc</s>
   <s>abc</s>
   <s>l</s>
</indexOf>

concat Function

Concatenates two or more string values.

Example

The following expression returns <s>Now is the time</s>.

<concat>
   <s>Now </s><s>is </s><s>the </s><s>time</s>
</concat>

downcase Function

Takes a single argument, which is coerced to a string. It returns a copy of the argument with all upper case letters converted to lower case.

Example

The following expression returns <s>abc</s>.

<downcase><s>ABC</s></downcase>

length Function

Returns the number of elements in the list. You can also use this function to return the length of a string.

first argument– list or string

Example 1

The following expression returns 2.

<length>
   <list>
      <s>apples</s>
      <s>oranges</s>
   </list>
</length>

Example 2

<length>
   <s>Hello world!</s>
</length>

This expression returns a value of 11.

ltrim Function

Takes a single argument, which is coerced to a string.

It returns a copy of the argument with the leading white space removed.

Example

The following expression returns <s>hello</s>.

<ltrim><s> hello</s></ltrim>

match Function

Deprecated. Use the contains function instead.

message Function

Formats a message by message catalog key.

Example

<message severity-’ok’ name=’DEFAULT_MESSAGE’>
   <!--message parameter 0-->
   <!--message parameter n-->
</message>

pad Function

Pads a string with spaces so that it reaches a desired length.

first argument– the string to pad

second argument– desired length

third argument– (optional) specifies the pad character, which by default is a space

Example

The following expression results in <s> email </s>

<pad>
   <s> email</s>
   <i>10</i>
</pad>

rtrim Function

Takes a single argument, which is coerced to a string. It returns a copy of the argument with the trailing white space removed.

Example

This example returns 0 (zero).

<cmp>
   <s>hello</s><rtrim><s>hello   </s></rtrim>
</cmp>

split Function

Splits a string into a list of strings.

first argument– string to be split

second argument– a set of one or more string delimiters. Each character in this string will cause a break.

A list is created that contains each substring between delimiters.

Example 1

<split>
   <s>Austin City Limits</s>
   <s> </s>
</split>

This expression returns the following list.

<list>
   <s>Austin</s>
   <s>City</s>
   <s>Limits</s>
</list>

Example 2

The following expression uses multiple delimiters.

<split>
   <s>(512)338-1818</s>
   <s>()-</s>
</split>

This expression returns the following list.

<list>
   <s>512</s>
   <s>338</s>
   <s>1818</s>
</list>

substr Function

Extracts ranges of characters from a string.

This function takes two forms:

For example, these two invocations are equivalent:

<substr>
    <s>Hello World</s>
      <i>3</i>
      <i>4</i>
<substr>

and

<substr s=’3’ l=’4’>
    <s>Hello World</s>
<substr>

Both functions return the string lo W.

<block>
    <substr s=’3’ l=’4’>
       <s>Hello World</s> --> Hello World
    </substr> --> lo W
</block> --> lo W

The start and length parameters are optional. If the start argument is missing, either because only the string is specified as a child of the substr node as in

<substr>
    <s>Hello World</s>
 <substr>

and the attribute s is also missing from the substr node, the start is assumed to be the beginning of the string. In other words, its value is zero if not specified explicitly.

first argument– string

second argument– starting position

third argument– number of characters to retrieve

Examples

The following expression returns <s>Now</s>.

<substr>
   <s>Now is the time</s>
   <i>0</i>
   <i>3</i>
</substr>

In the following example, the start attribute is missing, but is assumed to be 0:

<block>
    <substr l=’4’>
        <s>Hello World</s> --> Hello World
    </substr> --> Hell
</block> --> Hell

The length argument is also optional. A missing length argument causes the function to extract the rest of the string. length can be unspecified when only the string and start arguments are specified a child nodes of substr such as:

<substr>
    <s>Hello World</s>
        <i>3</i>
<substr>

or when the l attribute is missing from the substr node like. Note that the length argument is unspecified below, but the rest of the string starting from this start is returned:

<block>
    <substr s=’3’>
       <s>Hello World</s> --> Hello World
    </substr> --> lo World
</block> --> lo World

trim Function

Takes a single argument, which is coerced to a string.

It returns a copy of the argument with the leading and trailing white space removed.

Example

The following expression returns <s>hello</s>.

<trim><s> hello </s></trim>

upcase Function

Takes a single argument, which is coerced to a string.

It returns a copy of the argument with all lower case letters converted to upper case.

Example

The following expression returns <s>ABC</s>.

<upcase><s>abc</s></upcase>

ztrim Function

Returns the string value of the subexpression with leading zeros removed.

Example

<ztrim>
   <s>00000sample</s>
</ztrim>
This function evaluates to <s>sample</s>.