Table of Contents

Find(text, look_for)

Category: Text function


Description

This function finds the exact position of look_for within text and returns the position of the first character. If look_for is not found within text then it returns 0.

The first character in text has an index of 1.


Alternative syntax

This function can take an optional third numeric parameter to define the instance of look_for to find. If instance_num is negative, the search starts from the end of text.

Find(text, look_for, instance_num)


Arguments

ArgumentTypeDescription
textTextThe text value to search within for the look_for string.
look_forTextThe text string to search for within text.
instance_num*Number (non-zero integer)The occurrence of look_for to find.

*Optional argument.

Return value type: Number


Remarks

This function is case sensitive.

Both arguments are implicitly converted to text values if required.


Examples

find('New York', 'York') //Returns 5
find('New York', 'New') //Returns 1
find('New York', 'Dallas') //Returns 0
find('New York New York', 'York') //Returns 5  (Returns the position of the first instance only)
find('New York New York', 'York', 2) //Returns 14  (The second instance)
find('a/b/c/d', '/', 2) //Returns 4  (The second '/' from the start)
find('a/b/c/d', '/', -1) //Returns 6  (The last '/')
find('a/b/c/d', '/', -2) //Returns 4  (The second '/' from the end)
find('New York', 'new') //Returns 0  (Unmatched due to case)
find([City], 'Ant') //Returns 5  (Using a field name; [City] = 'San Antonio')
find(1200, 2) //Returns 2  (Numeric values are converted to text implicitly)


See also