ARPUS/ce, Version 2.6.2 (03/10/05) (SCCS 1.4) _______________________________________________________________________________ Concept: Regular expressions. DESCRIPTION: Regular expressions are used to find patterns of characters in a text region. ce supports the use of both AEGIS regular expressions and Unix expressions (a la the Unix 'ed' command). Only one style applies per edit session, and that style is determined by the '-expr' command line option or the 'Ce.expr' X resource when ce is started. AEGIS regular expressions and Unix regular expressions have much in common. Nonetheless, the following descriptions treat the styles separately; this DESCRIPTION section concludes with a table summarizing the similarities between the two styles. AEGIS REGULAR EXPRESSIONS Special Character(s) Meaning ------------------------------------------------------------------- % matches beginning of line, but only if it is the first character in the expression; otherwise it is interpreted literally $ matches end of line, but only if it is the last character in the expression; otherwise it is interpreted literally ? matches any single character except newline * matches 0 or as many occurrences of the preceding character as can be matched, but only if this is NOT the first character in the expression; otherwise it is interpreted literally, since there is no preceding character @f matches a form feed character (hex 0C) @n matches a newline character (hex 0A) @t matches a tab character (hex 09) @c matches the literal character 'c'; this is used primarily to match a character that normally serves as a special regular expression character; for example '@?' will match a literal '?' [string] matches one occurrence of any character found in string; for example, '[abyz]' will match the first occurrence of either an 'a', 'b', 'y', or 'z'; 'string' may also indicate ranges of characters, so that '[a-cx-z4-6]' would match 'a', 'b', 'c', 'x', 'y', 'z', '4', '5', or '6'; to include a literal '~', ']', '-', or '@' in 'string', precede the character with '@' [~string] matches one occurrence of any character that is NOT found in string; if '~' appears in 'string' but is not the first character, it is treated as a literal '~'; the same rules regards ranges of characters and inclusion of special characters in 'string' described above apply here {expr} the curly brackets are used to 'tag' an expression so that a string that matches the given expression can be referenced in a substitution operation; for example, the substitute command 's/{[abc]}?/+@1+/' means that for every occurrence of an 'a', 'b', or 'c' (i.e. '{[abc]}') followed by a single character (i.e. '?'), replace the occurrence with a '+' followed by the 'a', 'b', or 'c' (i.e. '@1') followed by another '+'; you can tab up to nine expressions, i.e., '@1' ... '@9' All other characters appearing in an AEGIS regular expression are treated literally. UNIX REGULAR EXPRESSIONS Special Character(s) Meaning ------------------------------------------------------------------- ^ matches beginning of line, but only if it is the first character in the expression; otherwise it is interpreted literally $ matches end of line, but only if it is the last character in the expression; otherwise it is interpreted literally . matches any single character except newline * matches 0 or more occurrences of the preceding character, but only if this is NOT the first character in the expression; otherwise it is interpreted literally, since there is no preceding character \c matches the literal character 'c'; this is used primarily to match a character that normally serves as a special regular expression character; for example '\?' will match a literal '?' [string] matches one occurrence of any character found in string; for example, '[abyz]' will match the first occurrence of either an 'a', 'b', 'y', or 'z'; 'string' may also indicate ranges of characters, so that '[a-cx-z4-6]' would match 'a', 'b', 'c', 'x', 'y', 'z', '4', '5', or '6'; to include a literal '^', ']', '-', or '\' in 'string', precede the character with '\'; if ']' is the first character in 'string', it is interpreted literally and not as the terminating ']'; [^string] matches one occurrence of any character that is NOT found in string; if '^' appears in 'string' but is not the first character, it is treated as a literal '^'; the same rules regards ranges of characters and inclusion of special characters in 'string' described above apply here c\{m\} matches a string containing exactly 'm' occurrences of the character 'c', where 'c' is either a literal character or a single character pattern; similarly, 'c\{m,\}' matches at least 'm' characters, and 'c\{m,n\}' matches between 'm' and 'n' characters; m and n must both be integers between 0 and 256; in this form of regular expression, the curly brackets '{}' and backslashes '\' are required \(pat\) matches pat \n matches the same pattern matched by an expression enclosed between '\(' and '\)'; for example, '\(abc\)\5' matches the string 'abcabcabcabcabc' All other characters appearing in an Unix regular expression are treated literally. TABLE OF SIMILARITIES BETWEEN AEGIS AND UNIX REGULAR EXPRESSIONS Meaning AEGIS Unix ------------------------------------------------------------------- Beginning of line % ^ End of line $ $ Single character ? . 0 or more occurrences of prev char * * Escape character @ \ One character of a set [string] [string] One character not in a set [~string] [^string] Repeating patterns c\{m,n\} \(pat\) RELATED HELP FILES: / (Forwards Search) \ or ? (Backwards Search) abrt (Abort) sq (Search Quit) re (Regular Expression) s (Substitute) so (Substitute Once) sc (Set Case Comparison) support (customer support) _______________________________________________________________________________ Copyright (c) 2005, Robert Styma Consulting. All rights reserved.