search_first

This function searches the first occurrence of a substring in a string. The search can be performed either case sensitive or case insensitive.

ASSIGN offset := search_first (haystack; needle; case_sensitive)

The result of the function search_first is of type NUMBER. This function has three parameters:

  1. haystack, type TEXT; the text that the search is performed in.
  2. needle, type TEXT; the text that is located.
  3. case_sensitive, type BOOL; TRUE if the search is case-sensitive, FALSE if the case of the parameters haystack and needle are ignored.

The result of the function search_first is the offset of the first occurrence of the parameter needle in the parameter haystack. If the text could not be found the function search returns 0.

Notes

Case insensitive searches are performed by converting both the parameters haystack and the needle to lower case before performing the search.

The function search_first is designed to handle Unicode input. Non-printable word processor instructions are ignored, similar to the behavior of the function fragment_of_characters.

Example

search_first ("The Quick Brown Fox Jumps Over The Lazy Dog"; "o"; FALSE)

Result: 13.