Programmer's WorkBench (pwb.hlp) (Table of Contents; Topic list)
Non-UNIX Regular Expressions
                                             Up Contents Index Back
─────Programmer's WorkBench─────────────────────────────────────────────────
 
     PWB uses the following non-UNIX regular-expression syntax:
 
     Syntax         Description
 
     \c          Escape: matches a literal occurrence of the character
                 <c> and ignores any special meaning of <c> in a
                 regular expression.
 
                 For example, the expression '\?' matches a question
                 mark '?', the expression '\^' matches a caret '^', and
                 the expression '\\' matches a backslash '\'.
 
     ?           Wildcard: matches any single character.
 
                 For example, the expression 'a?a' matches 'aaa' and
                 'a1a' but not 'aBBBa'.
 
     ^           Beginning of line.
 
                 For example, the expression '^The' matches the word
                 'The' only when it occurs at the beginning of a
                 line.
 
     $           End of line.
 
                 For example, the expression 'end$' matches the word
                 'end' only when it occurs at the end of a line.
 
     [class]     Character class: matches any one character in the
                 class. Use a dash (-) to specify ranges. Within a
                 class, all characters except ~-\] are treated
                 literally.
 
                 For example, '[a-zA-Z*]' matches any alphabetic
                 character or asterisk, and '[abc]' matches a single
                 'a', 'b', or 'c'.
 
     [~class]    Inverse of character class: matches any single
                 character not in the class.
 
                 For example, '[~0-9]' matches any character that is
                 not a digit.
 
     x*          Minimal matching: matches zero or more occurrences of
                 <x>, where <x> is a single character or a group of
                 characters enclosed in parentheses (()), brackets
                 ([]), or braces ({}).
 
                 For example, the regular expression 'ba*b' matches
                 'baaab', 'bab', and 'bb'.
 
     x+          Minimal matching plus (shorthand for xx*): matches one
                 or more occurrences of <x>.
 
                 For example, the regular expression 'ba+b' matches
                 'baab' and 'bab' but not 'bb'.
 
     x@          Maximal matching: identical to x*, except that it
                 matches as many occurrences as possible.
                 See: Non-UNIX Matching Method
 
     x#          Maximal matching plus: identical to x+, except that
                 it matches as many occurrences as possible.
                 See: Non-UNIX Matching Method
 
     (x!y!z)     Alternation: matches one from a set of alternate
                 patterns. The alternates are tried in left-to-right
                 order. The next alternate is tried only when the rest
                 of the pattern fails.
 
                 For example, the regular expression '(ww!xx!xxyy)zz'
                 matches 'xxzz' on the second alternative and 'xxyyzz'
                 on the third.
 
                 TIP: To match zero or one occurrences of a pattern,
                      use alternation with an empty alternative:
 
                           (x!)
 
                      This specifies one occurrence of <x> or nothing.
 
     (x)         Grouping. Groups a regular expression so that you can
                 use a repeat operator on the subexpression.
 
                 For example, the regular expression '(Test)+' matches
                 'Test' and 'TestTest'.
 
     ~x          "NOT" function: matches nothing but checks to see if
                 the text matches <x> at this point and fails if it
                 does.
 
                 For example, '^~(if!while)?*$' matches all lines that
                 do not begin with 'if' or 'while'.
 
     x^<n>       Power function: matches <n> copies of <x>.
 
                 For example, 'w^4' matches 'wwww', and '(a?)^3'
                 matches 'a#aba5'.
 
     {x}         Tagged expression: marked text, which you can refer to
                 as '$n' elsewhere in the find or replacement string.
                 Within a find string, PWB finds text that contains the
                 tagged text. Within a replacement string, PWB reuses
                 the matched text in the replacement.
 
     $n          Reference to text matched by a tagged expression.
 
                 The specific substring is indicated by <n>. The first
                 tagged substring is indicated as '$1', the second as
                 '$2', and so on. A '$0' represents the entire match.
 
     :e          Predefined regular expression, where <e> is a letter
                 that specifies the regular expression.
                 See: Predefined Regular Expressions
                                    -♦-