[ < < < Home ]
[ < < Reference Start ]
[ < Reference Contents ]
[ < Previous=PDGREPPE Magic Patterns ]
[ Next=PDGREPPE Search Operators > ]
Magic Expressions consist of Operators, Terms, Factors and/or Atoms and Controls Operators: A reference or comparison or functional feat performed on some item of data can be considered an operator. Operators are the "doers". They DO something provided they have something to work with. An expression may have math operators like Boolean AND and OR operators that test for one thing versus another. Or there may be quantity determination operators that test for some number of repeated data. Each operator can work with some simple or complex data element called a term. Terms: A Term is one or more items of data. It is acted upon by ONE operator such as OR or AND. Terms are the "things" that "doers" can work with. Each Term of an Expression can be composed of one or more Factors or Atoms. Factor: Each factor is a data part or position that can determine if there is a match to a section of data A factor can be some small "atomic" part like a single byte or block of bytes or a position. Or a Factor can itself be an Expression. This is what allows complex yet powerful pattern-matching to be done. So a Factor can be either the smallest through the LARGEST potential thing in a pattern. Atom: An atom, like a factor is part of a pattern, but refers to the SMALLEST part of something definite to be searched for. An atom can be the "point" that is found at every position in a file, some other position, a specific byte, character or multiple byte section. What follows is a semi-ordered group of explanations of various pattern matching Actions and their associated Symbols that represent Operators working with Terms that contain one or more Factors. Controls: These control something being done while searching or replacing but do not themselves define any search/replace item. Controls are like functions rather than data. Precedence: Different parts of a magic pattern are taken into consideration before others. For example: Groups like "{c|d}" of ab{c|d}ef or "(c|d)" of ab(c|d)ef that isolate "ab" from "c", and "ef" from "d", have a higher precedence than parts outside groups. The innermost group has the highest precedence. Quantity operations like abc+ have higher precedence than adding or joining atoms so that the item "c+" is drawn out for the repeat "+" function first before having the string "ab" added to the expression. Therefore the repeat or quantity operation has HIGHER precedence than adding atoms. Or a pattern like "abc|def" makes two separate sections of abc and def before creating an expression that involves the OR "|" operator. So the adding of adjoining atoms to make sections takes place before emplacing a OR or AND operation. This is then a HIGHER level of precedence than OR and AND operations. Also, there is a direction the pattern is processed when parts are placed by preference, sometimes left to right and sometimes right to left. Following is a table that shows various pattern parts, direction of interpretation: PART ELEMENTS DIRECTION Expression () {} #<n> definition left to right Atom byte [<set>] position file left to right multibyte Quantity ;?-!?*+ or [;?-!?*+]{j,k} right to left Additive ie concatenation (eg abc) left to right OR/AND | ~ & left to right Table of Pattern Parts Precedence (Highest to Lowest)
[ < < < Home ]
[ < < Reference Start ]
[ < Reference Contents ]
[ < Previous=PDGREPPE Magic Patterns ]
[ Next=PDGREPPE Search Operators > ]
© Intelligence Services 1987 - 2008
GPO Box 9, ADELAIDE SA 5001, AUSTRALIA
EMAIL : intlsvs@gmail.com