Sun Identity Manager Deployment Reference

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