search ?-w win? ?options? pattern pos
Search for pattern starting from position pos. The available options are:
-f (0|1)search backward or forward (default 1)
-r (0|1)pattern is a regular expression (default 0)
-i (0|1)ignore case (default 0)
-m (0|1)match words (default 0)
-l poslimit on how far search goes
-allreturn all matches
-wrapwrap around
-nfailed search returns empty string rather than raising an error
--end of the options
For a literal search (-r 0), one can additionally specify the following:
-di (0|1)diacritics insensitive (default 0)
For a regular expression search (-r 1), one can additionally specify the following:
-d (0|1)allow dot to match any character, including line separators (default 0)
-ml (0|1)allow ^ and $ to match the start and end of lines (default 1)
-u (0|1)treat only \n as a line separator (default 0)
-uts (0|1)use Unicode text segmentation to specify word boundaries (default 0)
-x (0|1)allow spaces and #-prefixed comments in the pattern (default 0)

The pos argument is the first position at which a search may match (whether searching forwards or backwards). The limit argument, if given, is the first position at which a search will not match.
If the search succeeds, a list of two positions will be returned, unless the option
-all was given, in which case the command returns a list of two-element sublists for each correct match. The first element is the starting position of the match, the second is one past the last character. If there is no -n option, an error is thrown if no match was found: it is common practice to wrap this command in a [catch] statement to capture the error.
When the -wrap option is specified, then if the search reaches the end of the window, it wraps around to the beginning and continues searching (similarly when searching backwards, it wraps from beginning to end). Note that the interpretation of pos is such that backwards searches may match immediately at pos, in which case the entire matched range will be outside the apparent [limit,pos] search region.
For the syntax of regular expressions, see the
Regular Expressions help file. Note that, by default, the Match Lines option (-ml) is set to 1 for regular expression searches (see the Flag Options section).
The option -di is supported only for literal searches (i-e if the -r option is set to 0). If it is set to 1, diacritic marks are ignored: for example, ö is equal to o.
The options -d, -ml, -u, -uts and -x are meaningful only if the -r option is set to 1. If the -u option is set to 0, all standard line separators are used, otherwise only the Unix line separator \n is used. The -i, -d, -ml, -x options can also be set in the regular expression pattern itself using (?ismx-ismx) directives. The -uts option enables Unicode text segmentation (word boundaries) as defined in the Unicode Standard Annex UAX #29.