Page tree

_find

The Find formula finds a sub-sequence of the input sequence that matches the pattern and returns true if, and only if, a sub-sequence of the input string matches the specified pattern.

Syntax

find(pattern, text[,flags])

Examples

find("flour", $ingredients)

This formula returns true if the text "flour" is found in the text field $ingredients.

find("flour", $ingredients,"im")? "Contains Gluten": "Gluten Free"

Returns "Contains Gluten" if "flour" or "Flour" is found in the $ingredients field, else it returns "Gluten Free". Multi-line mode is enabled.

Flags

Case-insensitive matching and multi-line mode are enabled by the optional flags "i" and "m" respectively, or "im" to enable both.
For example, the expression find("flour", $ingredients, "im") will return "true" if the sequence "flour" or "Flour" is found, and "false" if it is not.

Notes

The find function accepts only strings as arguments.  You can force the system to evaluate some non-string data types as strings by adding an empty string with +"".  For instance, a link to single fields from other table with multiple values enabled (MVE) is not stored as a string. If the "find" function is used to look for some value such as "anonymous" in a multi-value linked field (MLF) called External CCs, the formula might look like the following:

find("anonymous", $external_cc+"")

By adding an empty string to the MLF value - using +"" - the MLF value is converted into a string for search purposes.

Example
find("apples",""+$selected_fruit,"i")

Returns true if the multi-value linked field $selected_fruit contains "apples" or "Apples" or "aPPles".






CONTENTS
  • No labels