Obtains the index of the first ocurrence of a word in the text and returns its position.
1 string.indexOfWord
<string.indexOfWord>
<text /> !
<word /> !
</string.indexOfWord>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Etext | string | ||||
Eword | string |
Returns | |
---|---|
Type | Description |
integer | Returns the position which occupes the first ocurrence of a word in a text, in an isolated way (does not found substrings, if not the word complete and alone). If it is not found, the system returns 1. |
Exceptions
requires 2 arguments, received: ...
The 2 entry parameters has not been specified.
Remarks
This function only obtains the searched text if is between spaces, that is, if it is found in isolation in the text, otherwise it returns -1.
Example
Obtains the index to a word in the text and returns its position.
Copy
<xsql-script name='string_indexOfWord'> <body> <set name='text'>The students played basketball in the stadium next to the church</set> <set name='word'>the</set> <println> <string.indexOfWord> <text /><word /> </string.indexOfWord> </println> </body> </xsql-script>
Returns:
Copy
34