STR_FIND

Use the STR_FIND script function to search for a character or a string in a string. The search is not case sensitive.

Syntax

STR_FIND (String1, String2[, Start])

Parameters

  • STR_FIND

    Searches for a characters or a string in a string

  • String1

    An alphanumeric string in which you want to search

    Format: script literal or script variable

  • String2

    A single character or an alphanumeric string that your search for.

    Format: script literal or script variable

  • Start

    (Optional) Position where the search should start. The script function looks for String2 in String1. If not defined, the search begins at the first position.

    Format: number without quotation marks

    Default value: 1

Return codes

  • Position where the character or string was found
    Note: The script function returns the first position where the character or string that is defined in String2 was found. The position is counted from the beginning of String1, not from the position that is specified in Start.

  • 0
    The character or string could not be found

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 Automic#01, Automic#02 strings 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 term that you search for is at 13.

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

:PRINT &POS#

See also: