Compaq AA-PWCBD-TE Computer Accessories User Manual


 
DEC Text Processing Utility Data Types
3.7 Pattern Data Type
Given this sequence of definitions, a search for pat_var succeeds if DECTPU
encounters the following string:
a5xcd
Because two pattern variables are linked, DECTPU searches first for the text
that matches p1, then unanchors the search, and then searches for the text that
matches p2.
To specify an anchored search when the right-hand subpattern is a pattern or
keyword variable, use a plus sign ( + ). You must use a plus sign ( + ) to anchor
the search if the right-hand subpattern is a keyword variable. If the right-hand
subpattern is a pattern variable, you can use the ANCHOR keyword as the first
element of that subpattern to anchor the right-hand subpattern.
For example, suppose you defined the following patterns:
p1 := LINE_BEGIN + "a";
p2 := "b" + LINE_END;
You anchor the search for p2 by using ( + ) as follows:
pat_var := p1 + p2;
If you use an ampersand ( & ), you unanchor the search for p2.
You can also anchor the search for p2 by defining p2 as follows:
p2 := ANCHOR + "b" + LINE_END;
3.7.3.3 | (Pattern Alternation Operator)
The alternation operator ( | ) tells SEARCH or SEARCH_QUIETLY to match a
sequence of characters if those characters match either of the pattern elements
separated by the alternation operator. The following pattern matches either the
string abc or the string xes:
pat1 := "abc" | "xes";
If the text being searched contains text that matches both alternatives, SEARCH
or SEARCH_QUIETLY matches the earliest occurring match. If two matches
start at the same character, SEARCH or SEARCH_QUIETLY matches the left
element. For example, suppose you had the search text abcd and the following
pattern definitions:
pat1 := "abc" | "bcd";
pat2 := "bcd" | "abc";
pat3 := "bc" | "bcd";
pat4 := "bcd" | "bc";
Given these definitions and search text, a search for the patterns pat1 and pat2
would return a range that contains the text abc. A search for the pattern pat3
would return a range that contains the text bc. Finally, a search for the pattern
pat4 would return a range that contains the text bcd.
3.7.3.4 @ (Partial Pattern Assignment Operator)
The partial pattern assignment operator ( @ ) tells SEARCH or SEARCH_
QUIETLY to create a range that contains the text matching the pattern element
to the left of the partial pattern assignment operator. When the search is
completed, the variable to the right of the partial pattern assignment operator
references the created range. If SEARCH or SEARCH_QUIETLY is given the
search text abcdefg and the following pattern, it returns a range that contains the
text abcdefg:
3–14 DEC Text Processing Utility Data Types