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>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Etext | string | ||||
Esubtext | string | ||||
Eindex | integer | This argument is optional. If informed indicates that the text has to be searched from the position indicated here, it is not found in the part of text previous to this position. |
Returns | |
---|---|
Type | Description |
Integer | Returns the index of the first coincidence in which the value of the second argument is found in the first one. Returns -1 if it is not found and 0 if the string to found is null. |
Exceptions
requires 2 arguments, received: ...
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.
Determines if the substring of the second argument is found in the text or string of the first argument.
<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:
-1 12
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.
<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:
72