![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() ![]() |
Another selecting mechanism uses regular expressions to select items. This feature can be used in addition to the selection according to aux files. The regular expression syntax is identical to the one used in GNU Emacs. For a description see section Regular Expression Matching.
The resource select allows to specify which fields should be used to select entries. The general form is as follows:
select = {field1 ... fieldn "regular_expression"}
If no field is specified then the regular expression is searched in each field. If no regular expression is specified then any value is accepted; i.e. the regular expression "." is used.
Any number of selection rules can be given. An entry is selected if one of those rules selects it. The select rule selects an entry if this entry has a field named field which has a substring matching regular_expression. The field can be missing in which case the regular expression is tried to match against any field in turn.
The pseudo fields $key
, $type
, and @
type can be
used to access the key and the type of the entry. See page
Pseudo Fields for details. The routines used there are the same as those
used here.
Analogously to the negation of the string matching the regular expression matching can be negated. The resource to perform this functionality is select.non. The general form is
select.non = {field1 ... fieldn "regular_expression"}
The boolean resource select.case.sensitive can be used to determine whether the selection is performed case sensitive or not:
select.case.sensitive = off
Note that the selection does not take place immediately. Instead all selection rules are collected and the selection is performed at an appropriate time later on. The different selection rules are treated as alternatives. Thus any entry which matches at least one of the rules is selected. Nevertheless the value of the resource select.case.sensitive is used which is in effect when the selection rule is issued. Thus it is possible to mix case sensitive rules with non-case sensitive rule.
A regular expression can be specified in the command line using the option -X as in
bibtool -X regular_expression
The fields compared against this regular expression are given in the string
valued resource select.fields. Initially this resource has the value
$key
. In general the value is a list of fields and pseudo fields to be
considered. The elements of the list are separated by spaces. If the list is
empty then all fields and the key are considered for comparison.
Thus the following setting means that the regular only the fields author
and editor
are considered when doing a selection.
select.fields = "author editor"
Without changing the resource select.fields the command line given previously is equivalent to the (longer) command
bibtool -- select{$key "regular_expression"}
Note that the resources select.case.sensitive and select.fields are used for all regular expressions following their definition until they are redefined. This means that it is possible to specify that some comparisons are done case sensitive and others are not done case sensitive.
Finally the resource extract.regex can be used as in
extract.regex = {regular_expression}
This is equivalent to specifying a single regular expression to be matched against the key. This feature is kept for backward compatibility only. It is not encouraged and will vanish in a future release.
![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() ![]() |