STR_FIND

Script Function: It searches for a character or a string in a string.

Syntax

STR_FIND (String1, String2[, Start])

Syntax

Description/Format

String1

An alphanumeric string in which the search should take place.
Format: script literal or script variable

String2

An individual character or alphanumeric string that is searched.
Format: script literal or script variable

Start

The position where a search should begin.
Format: Number without quotation marks
Default value: 1


Return codes

Position where the character or string was found
"0" - The character or string was not found

The function STR_FIND looks for String2 in String1 beginning at position Start. If Start is not specified, the search begins at position 1. String2 can consist of one character. The search is not case sensitive.

The script function returns the first position where String2 has been found. The position is counted from the beginning of String1, not from the position specified by Start.

Examples

The following script returns the position within a string where a given string is found.

:SET &LOCATION# = STR_FIND("AE system", "system")

The result is 4 because the first character of the search term is the fourth character in the string.

In the following example, the search for the character # in the string Automic#01, Automic#02 returns the value 8:

:SET &STRING#="Automic#01, Automic#02"
:
SET &SEARCHSTRING#="#"
:
SET &POS#=STR_FIND(&STRING#,&SEARCHSTRING#)
:
PRINT &POS#

In the following example, the search starts at position 2, so the position of the search term is at 13.

:SET &POS#=STR_FIND("AUTOMIC#01, AUTOMIC#02","AUTOMIC", 2)

:PRINT &POS#

See also:

seealso

Script Elements for Editing Strings