Import Filter Expressions
This section provides a general description of data filters.
An import filter is the same as any other filter in Studio products; an English-like expression that is used to make selections from string, drillhole, wireframe and model data.
Filters can be applied to loaded data objects or to create a subset of data to import or load. The expressions used in either case are in the same format, described here.
Filter expressions contain a number of relational and/or pattern matching expressions. The following sections outline the grammar required by filters, and provide usage examples.
Relational Expressions
The syntax of a relational expressions can be any of the following:
-
[FIELD] [CONSTANT]
-
[FIELD] [FIELD]
-
[CONSTANT] [FIELD]
The keywords FIELD and CONSTANT are optional, and need only be specified to avoid confusion (for example, "ROCKTYPE==FIELD T2" or "ROCKTYPE==CONSTANT T2").
Any of the six relational operators (">", ">=", "==", "<=", "<" or "!=") may be used.
Note: "=" and "<>" are also recognized to allow compatibility with PICxxx processes.)
Pattern Matching Expressions
A pattern matching expression is used to find data items that follow a particular syntax pattern.
The following syntax can be used for pattern matching regular expressions:
-
MATCHES [REGEXP]
If the keyword REGEXP is missing, a "pattern" may consist of literal characters to be matched, or one of the following elements:
-
? Any single character.
-
* A group of zero or more characters.
-
[...] Any one of the characters enclosed in the square brackets. The shorthand notation "a-z" means any lowercase letter.
-
[^...] Any character except one of these.
The special meaning of a character (e.g. "*") is lost if the character is preceded by "\", hence to match a literal "*", use "\*".
Note: If your field name or constant value begins with the first three characters of a keyword, then it should be prefixed with "\" to disambiguate it (see note on parser error 120 at the end of examples section).
Quotes (double or single) may be used to enclose patterns if desired.
If the keyword REGEXP is included, the pattern may be a full regular expression similar to those used by various UNIX utilities. Regular expressions allow advanced users to make more complex selections than are possible by using the pattern elements specified above.
A regular expression may contain the following elements:
-
% Matches the beginning of the field value.
-
$ Matches the end of the field value.
-
* Zero or more occurrences of the preceding pattern element.
-
? As above.
-
[...] As above.
-
[^...] As above.
Concatenation of Expressions
The result of a relational or pattern matching expression is either TRUE or FALSE. Any result may be inverted by preceding the expression by the keyword "NOT" (e.g. "NOT BHID MATCHES RDH*").
Two expressions may be joined together by "AND" or "OR" operators, resulting in another expression.
Note: The "AND" operator has higher precedence than "OR".
Parentheses (brackets) may also be used to override the normal order of evaluation of expressions.
Examples
Use the following examples for guidance:
-
Select records where the first three characters of field BHID are "RDH", and the XCOLLAR field is between 10200 and 11200:
BHID MATCHES RDH* AND XCOLLAR>=10200 AND XCOLLAR<=11200 -
Select records where the contents of field "Au1" is greater than the contents of field "Au2":
Au1 > Au2 -
Select records where the contents of field "CONTACT" include the character "?".
FIELD \CONTACT MATCHES "*\?*"Note: The "\" before the field name "CONTACT" is used to distinguish it from the reserved keyword "CON(stant)" .
Note also the "\" before "?" to disable its special meaning as a pattern matching element.
-
Select records where an alphanumeric field "LOG" contains both codes "Cu" and "Pb", in any order, anywhere within the field text, and in upper or lower or mixed case:
LOG MATCHES*[cC][uU]*[pP][bB] OR LOG MATCHES *[pP][bB]*[cC][uU]* -
Select records where CODE is five characters long, but does not end in "3" or "4":
CODE MATCHES ????[^34]Alternatively, you could specify the following:
CODE MATCHES ????? AND NOT CODE MATCHES *[34] -
Select all records where ROCKCODE is 7, and BHID is DDH034, DDH147 or DDH136:
ROCKCODE==7 AND (BHID==DDH034 OR BHID==DDH147 OR BHID==DDH136)In the previous expression, the parentheses are required, since by default the expressions would be combined as follows:
(ROCKCODE==7 AND BHID==DDH034) OR BHID==DDH147 OR BHID==DDH136 -
If a file contains two alphanumeric fields called "ROCKTYPE" and "SHALE", the expression "ROCKTYPE==SHALE", is ambiguous. Either name could represent a field name, or a constant value. In order to resolve this, the grammar recognizes the optional keywords "FIELD" and "CONSTANT". The four possibilities are therefore :
FIELD ROCKTYPE == FIELD SHALE
FIELD ROCKTYPE == CONSTANT SHALE
CONSTANT ROCKTYPE == FIELD SHALE
CONSTANT ROCKTYPE == CONSTANT SHALEIf the keyword "FIELD" or "CONSTANT" does not appear, a name is treated as a field name if such a field exists. The last of the above examples (where neither ROCKTYPE nor SHALE is a valid field name) will result in a warning message, but is not considered to be an error.
Parser Error 120
If "ERR 120(0) in parser" is given in response to any file or field that has the same name as a filtering keyword, then precede that name with a backslash "\". For example, "FILE \MATCH".
Normally, keywords can be abbreviated to 3 characters or less. If the environment variable "MATCH_KEYWORD_IN_FULL" = YES, then possible ambiguity between keywords and names is reduced, as each keyword must be typed in full.
