search

This function searches a string from a specified location to the next occurrence of a substring. The search can be performed either case sensitive or case insensitive.

ASSIGN offset := search (haystack; needle; start; case_sensitive)

The result of the function search is of type NUMBER. This function has four parameters:

  1. haystack, type TEXT; the text that the search is performed in.
  2. needle, type TEXT; the text that is located.
  3. start, type NUMBER; the offset in the haystack where the search begins.
  4. 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 is the offset of the first occurrence of the parameter needle in the parameter haystack at or past the start offset. 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 search function 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 ("The Quick Brown Fox Jumps Over The Lazy Dog"; "o"; 20; FALSE)

Result: 27 (the "O" in "Over")