archie/release/base/help/english/set/search/=

139 lines
4.2 KiB
Plaintext
Raw Normal View History

2024-05-28 17:59:32 +02:00
The 'search' variable determines the kind of search performed on the
database by the 'prog' command, providing flexibilty on search times and
ranges.
'search' is a string variable whose value is one of the following:
(1) "sub"
Substring (case insensitive). A simple, everyday substring search. A
match occurs if the the file (or directory) name in the database
contains the user-given substring.
Example:
"is" will match "islington" and "this" and "poison"
(2) "subcase"
Substring (case sensitive). As above but the case of the
strings involved becomes significant.
Example:
"TeX" will match "LaTeX" but not "Latex" or "TExTroff".
(3) "exact"
Exact match. The fastest search method of all. The restriction is
that the user string (the argument to the 'prog' command) has to
_exactly_ match (including case) the string in the database. This is
provided for those of who who know just what you are looking for.
For example, if you wanted to know where all the "xlock.tar.Z" files
were, this is the kind of search to use.
(4) "regex" This is the DEFAULT search method.
ed(1) regular expressions. Searches the database with the user
(search) string which is given in the form of an ed(1) regular
expression.
NOTE: Unless specifically anchored to the beginning (with ^) or end
(with $) of a line, ed(1) regular expressions have ".*" prepended and
appended to them. For example, it is NOT NECESSARY to say
prog .*xnlock.*
since
prog xnlock
will suffice. Thus the regex match becomes a simple substring match.
There are also compound searches made up of combinations
of the above search methods in sequence:
exact_sub Try "exact". If no matches found use
"sub".
exact_subcase Try "exact". If no matches found use
"subcase"
exact_regex Try "exact". If no matches found use
regex.
An "ed(1) regular expression" (from here on called RE) is the particular
type of regular expression used in the "ed" editor under Unix. For those
who are interested in all the gory details of REs see the help for
"regex" (which is incomplete, at the moment :-(), otherwise what follows
should be sufficient for most needs.
A regular expression is a convenient way to search for a set of specific
strings matching a pattern. To be able to specify such a pattern with
only the ordinary set of printable character we have to co-opt some of
them. For example in a RE the period means _any_ single character,
while an asterisk, '*', means zero or more occurences of the *PRECEDING*
RE.
For example:
knob - matches any string containing the substring 'knob'
a*splat - matches strings that contain zero or more a's followed by the
string 'splat'
#.*# - would match anything containing a '#' followed by zero or more
occurences of _any_ character, followed by another '#'
Other special characters that may be useful are '[' and ']', which are
used together. They can be used to specify either a set of characters
to match or a set of characters to not match. An example of the first
case is:
[abcd]
which matches any of one of the four letters, while an example of the
second case is:
[^abcd]
in which the '^' _in_the_first_position_ means that any character _not_
in the list will be matched. As well, ranges can be specified with a
'-'.
[a-z]
matches any lower case letter and,
[^a-z]
matches any character other than a lower case letter. Furthermore, you
can specify multiple ranges such as:
[%@a-z0-9]
or
[^A-Za-z]
meaning: match '%' or '@' or any lower case letter or digit, and match
any character other than a letter, respectively.
When you want to match a character which has a special meaning you should
precede it by a backslash, '\'.
Some final examples of REs are:
[Mm]ac\.txt - match anything containg the string "Mac.txt" or
"mac.txt"
[^aeiou][^aeiou]* - match any string consisting entirely of non-vowels
foo-v[0-9]\.tar\.Z - match "foo-v0.tar.Z" through "foo-v9.tar.Z"
Good luck, and remember that many things can be found with only a simple
substring (e.g. latex).