<index-of>

Purpose/Function

Finds the starting index for the first instance of a substring of a given string, searching forwards.

Attributes

NAME

TYPE

DEFAULT VALUE

DESCRIPTION

string

java.lang.String

(required)

string to search

substring

java.lang.String

(required)

substring to find

from

int

0

starting position (index) of search

Elements

None.

ReturnValues

DEFAULT NAME

TYPE

DESCRIPTION

_indexOfResult

int

index of the first character of the substring

Examples

<ogrescript>
   <declare name="s0" string="woruqpoweiurvnsadbkjs;dlkfjoeiuw"/>
   <declare name="s1" string="sad"/>
   <declare name="i"/>
   <index-of string="${s0}" substring="${s1}">
	<return-value defaultName="indexOfResult" assignedName="i"/>
   </index-of>
   <echo message="${s1} starts at ${i}"/>
</ogrescript>
  • No labels