The supported operands are: numbers, strings, field names and parenthesized expressions.
The supported numeric literals are integer numbers and real numbers.
The usual sign character ‘-’ is used to denote negative values.
Integer values can be denoted in base 10, base 16 using the 0x
prefix, and base 8 using the 0
prefix. Examples are:
10000 0 0xFF -0xa 012 -07 -1342 .12 -3.14
String values are delimited by either the '
character or the
"
character. Whichever delimiter is used, the delimiter closing
the literal must be the same as the delimiter used to open it.
Newlines and tabs can be part of a string literal.
Examples are:
'Hello.' 'The following example is the empty string.' ''
The '
and "
characters can be part of a string if they
are escaped with a backslash, as in:
'This string contains an apostrophe: \'.' "This one a double quote: \"."
The value of a field value can be included in a selection expression by writing its name. The field name is replaced by a string containing the field value, to handle the possibility of records with more than one field by that name. Examples:
Name Email long_field_name
It is possible to use the role part of a field if it is not empty. So, for example, if we are searching for the issues opened by ‘John Smith’ in a database of issues we could write:
$ recsel -e "OpenedBy = 'John Smith'"
instead of using a full field name:
$ recsel -e "Hacker:Name:OpenedBy = 'John Smith'"
When the name of a field appears in an expression, the expression is applied to all the fields in the record featuring that name. So, for example, the expression:
Email ~ "\\.org"
matches any record in which there is a field named ‘Email’ whose value terminates in (the literal string) ‘.org’. If we are interested in the value of some specific email, we can specify its relative position in the containing record by using subscripts. Consider, for example:
Email[0] ~ "\\.org"
Will match for:
Name: Mr. Foo Email: foo@foo.org Email: mr.foo@foo.com
But not for:
Name: Mr. Foo Email: mr.foo@foo.com Email: foo@foo.org
The regexp syntax supported in selection expressions is POSIX EREs, with several GNU extensions. See Regular Expressions.
Parenthesis characters ((
and )
) can be used to group
sub expressions in the usual way.