NexJ Logo

Find()

Compares two specified strings of text to find where the second string occurs within the first string. This function takes two string values as arguments and returns an integer value. If the second string is found within the first string, the function returns the position where the second string starts within the first string. The positions of characters in a string are numbered from the left starting at zero. For example, the position before the first character is 0, and the position between the first and second character is 1. If the second string is not found within the first string, the function returns -1.

Syntax

Find(source_<text>, <text_to_find>)

Input

source_text

string

The text to search within.

text_to_find

string

The text to find within the source text.

Output

integer

Examples

  • The expression Find("The quick brown fox", "quick") returns 4.
  • The expression Find("The quick brown fox", "dog") returns -1.