Home > Contents > Index >
INDEXOF
Finds the index of a string within a string.
Syntax
<INDEXOF STR="STRING_VALUE
" WHAT="SEARCH_STRING
" OUTSTR="VAR_NAME
" INDEX="OFFSET
"/>Parameters
STR (required)
- String to search.
WHAT (required)
- Value of the string to search for within
STRING_VALUE
.
OUTSTR (required)
- Name of the variable to store the offset into
STRING_VALUE
of theSEARCH_STRING
.
INDEX (required)
- Offset in the source string to begin the search. The default for this parameter is 0.
Description
The
INDEXOF
tag finds the index of a specified string within another string. For more information about variables, see the Sites Developer's Guide.Error Numbers
The possible values of
errno
include:
Value Description 1 Substring was found. 0 Substring was not found.Example
This example looks for the index of test within the string, "This is a test".
<INDEXOF STR="This is a test" WHAT="test" OUTSTR="index" INDEX="0"/> <IF COND="Variables.errno=1"> <THEN> <CSVAR NAME="Variables.index"/> </THEN> </IF>The browser displays:
10The following example sets the
outstr
variable to-1
if the string isn't found:<SETVAR NAME="errno" VALUE="0"/> <INDEXOF STR="a lost dog found the way home to Boston from Alaska" WHAT="Florida" OUTSTR="myindex1" INDEX="0"/> <SETVAR NAME="myindex1" VALUE="errno:Variables.errno, outstr:Variables.myindex1"/>The value of
myindex1
is:
"errno:0, outstr: -1"
See Also
Home > Contents > Index > ![]()
Oracle XML Tag Reference
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.