search_last

Use the search_last function to search a text for the final occurrence of a fragment. The search can be performed either case-sensitive or case-insensitive.

 search_last ( haystack; needle; casing )

This function returns a value of type NUMBER.

The function has three parameters:

  1. haystack, type TEXT. The text that the search is performed on.
  2. needle, type TEXT. The fragment that is searched for.
  3. casing, type BOOL. When TRUE the search is case-sensitive; otherwise, case-insensitive.

The result of the search function is the offset of the final occurrence of the needle text fragment in the haystack text. If the needle fragment could not be found, the function returns 0.

If the casing parameter is FALSE, both needle and haystack are converted to lowercase before searching. Applications should account for this conversion in case characters do not have a stable conversion (for example, straße and STRASSE).

Input is always converted to Unicode Normalization Form C (NFC). Tabs, paragraph breaks, and line breaks are handled as characters. Other word processor content, such as layout switches and graphical objects, is stripped before the comparison. Paragraph breaks, and line breaks are considered equal for comparison purposes.

Example

 TEXT haystack := "The Quick Brown Fox Jumps Over The Lazy Dog" 
TEXT needle := "o"

search_last (haystack; needle; TRUE ) returns 42 (D'o'g)

search_last (haystack; needle; FALSE) returns 27 ('O'ver)

search_last (needle; haystack; TRUE ) returns 0