Returns the index of the first idea of the specified character.

If a character with value ch is produced in the sequence of characters which represents this String object, then the index is returned (in units of code Unicode) of the first idea.

# 1 string.indexOf

<string.indexOf>    <text /> !    <subtext /> !    <index /> ?</string.indexOf>

#### Exceptions

The 2 entry parameters has not been specified.

#### Remarks

The character position indexes start counting from 0 and not from 1. If the substring of the second argument in the string or text of the first argument is not found, the script will return -1 as result. Althrough, if the value of the second argument is null, the script returns as result the position 0.

Example

Determines if the substring of the second argument is found in the text or string of the first argument.

Copy
<xsql-script name='string_indexOf_2args'>
<body>
<set name='a'>This IS a STRING OF characters.</set>
<set name='b'>STRING</set>
<set name='c'>STRING</set>
<println><string.indexOf><a /><b /></string.indexOf></println>
<println><string.indexOf><a /><c /></string.indexOf></println>
</body>
</xsql-script>

Returns:

Copy
-1
12
Example

Determine if the substring of the second argument is found in the text or string of the first argument through the character which occupies the position number 23.

Copy
<xsql-script name='string_indexOf_3args'>
<body>
<set name='a'>The bat slept peacefully in the zoo, while the children murmured watching him.
</set>
<set name='b'>ba</set>
<println><string.indexOf><a /><b /><number>23</number></string.indexOf></println>
</body>
</xsql-script>

Returns:

Copy
72