scanFile ?matching-options? ?-l? ?(-m|-M)? ?(-all|-c|-s)? ?-e enc? ?-f pos? ?-t pos? ?-n? ?--? pattern file
Scan a file for a regular expression. By default, the command returns the index ranges (start and end positions in the file) of the first match found, or raises an error if no match is found. If the -n option is specified, the command returns an empty string rather than raising an error when no match is found.
If the -l option is specified, the command returns line ranges instead of character index ranges. If the -c option is specified, the command returns the count of matches (or the count of matching lines if the -l option is specified).
The -s option tells the command to report only the success status (1 if there is a match, 0 otherwise). The -all option tells the command to return all the matches and not only the first one. The -l, -m, -M and -all options are ignored if the -s option is specified.
The -f and -t options (which stand for from and to respectively) specify start and end positions to perform the search. By default, the command searches the entire file.
If the -m option is specified, the command returns the matches themselves rather than their indices. If it used in conjunction with the -l option, it returns the entire lines that contain the matches.
If the -M option is specified, the command appends the matches to the index or line ranges. The return value in that case is a list of two-element sublists: the first element of each sublist is the character index range (or line range if -l is specified) and the second element is the corresponding match itself (or matching block of lines if -l is specified).
Note that, with the -l option, if a line contains several matches, it is reported only once. The -m and -M options are mutually exclusive. If both were specified, the command raises an error.
The -e option lets you specify the file's encoding. By default, if this option is not specified, the command tries to read the file in UTF-8 encoding: if it fails, it will retry with MacRoman encoding. If that also fails, it tries to guess the encoding. The supported encoding names are the same as for the transcode command: see Encoding Names.
The following switches specify the regular expression's matching options:
-i (0|1)ignore case (default 0)
-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)
This command scans the file on disk, that is to say the file does not have to be edited in Alpha. If you want to match a regular expression in a document window, you should use the search command instead.