home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / regexp.doc < prev    next >
Text File  |  1987-08-27  |  5KB  |  104 lines

  1.  
  2.  
  3.  
  4.                                Regular Expresions
  5.      Regular expression syntax for ME.
  6.      [1]  char    Matches itself, unless it is a special character
  7.              (meta-character):
  8.              .  [ ] * + ^ $
  9.              If case-fold-search is TRUE, char will match both upper and
  10.              lower case.
  11.      [2]  .  Matches any character.
  12.      [3]  \  Matches the character following it, except when followed by
  13.              one of: ()1234567890<> adnwW (See [7] - [15]) It is used as an
  14.              escape character for all other meta-characters, and itself.
  15.              When used in a set ([4]), it is treated as an ordinary
  16.              character.
  17.      [4]  [set]  Matches one of the characters in the set. If the first
  18.              character in the set is ^, it matches a character NOT in the
  19.              set. A shorthand S-E is used to specify a set of characters S
  20.              up to E, inclusive. Note that case-fold-search has no affect
  21.              on sets.
  22.              To include - in a set: [-...], [^-...] or [...-]
  23.              To include ] in a set: [[...], [^[...] or [^-[...]
  24.              examples       matches
  25.              [a-z]         Any lowercase alpha
  26.              [^]-]         Any char except ] and -
  27.              [^A-Z]        Any char except uppercase alpha
  28.              [a-zA-Z0-9]   Any alphanumeric
  29.      [5]  *  Any regular expression form [1] to [4], followed by closure
  30.              char (*) matches zero or more matches of that form.
  31.      [6]  +  Same as [5], except it matches one or more.
  32.      [7]  \(  A regular expression in the form [1] to [10], enclosed as
  33.              \(form\) matches what form matches. The enclosure creates a
  34.              set of tags, used for [8] and for pattern substitution. The
  35.              tagged forms are numbered starting from 1.
  36.      [8]  \1 ... \9  A \ followed by a digit 1 to 9 matches whatever a
  37.              previously tagged regular expression ([7]) matched.
  38.      [9]  \<  Matches the beginning of a word.
  39.           \>  Matches the end of a word.
  40.              See (modify-syntax-entry) for what a word is.
  41.      [10]  \a  Matches an alpha character (same as [a-zA-Z]).
  42.      [11]  \d  [0-9]
  43.      [12]  \n  Matches an alphanumeric character:  [a-zA-Z0-9]
  44.      [13]  \<blank>  Matches whitespace.
  45.      [14]  \w  Matches a word character (as defined by the syntax tables).
  46.      [15]  \W  Matches a non-word character (as defined by the syntax
  47.              tables).
  48.      [16]   A composite regular expression xy where x and y are in the form
  49.              of [1] to [10] matches the longest match of x followed by a
  50.              match for y.
  51.      [17]   ^ $     a regular expression starting with a ^ character and/or
  52.              ending with a $ character, restricts the pattern matching to
  53.              the beginning of the line, and/or the end of line anchors.
  54.              Elsewhere in the pattern, ^ and $ are treated as ordinary
  55.              characters.
  56.  
  57.  
  58.                                 RE substitutions
  59.      In the replace string, the following characters have special meaning:
  60.      [1]  &  Substitute the entire matched string in the destination.
  61.      [2]  \n  Substitute the substring matched by a tagged subpattern
  62.              numbered n, where n is between 1 to 9, inclusive.
  63.      [3]  \char   Treat the next character literally, unless the character
  64.  
  65.  
  66.  
  67.  
  68.  
  69.              is a digit ([2]). Otherwise the text is inserted verbatim.
  70.  
  71.  
  72.      EXAMPLES
  73.         foo*.* matches: fo foo fooo foobar fobar foxx ...
  74.         fo[ob]a[rz] matches: fobar fooar fobaz fooaz
  75.         foo\\+ matches: foo\ foo\\ foo\\\ ...
  76.         \(foo\)[1-3]\1 (same as foo[1-3]foo, but takes less internal space)
  77.            matches: foo1foo foo2foo foo3foo
  78.         \(fo.*\)-\1 matches: foo-foo fo-fo fob-fob foobar-foobar ...
  79.  
  80.  
  81.      DIAGNOSTICS
  82.         No previous regular expression, Empty closure, Illegal closure,
  83.            Cyclical reference, Undetermined reference, Unmatched (, Missing
  84.            ], Null pattern inside \(\), Null pattern inside \<\>, Too many
  85.            \(\) pairs, Unmatched \).
  86.  
  87.  
  88.      AUTHOR: Ozan S. Yigit (oz)
  89.      MODIFIER: Craig Durland
  90.  
  91.  
  92.      BUGS
  93.         The internal storage for the compiled regular expression is not
  94.            checked for overflows. Currently, it is 512 bytes. If your RE's
  95.            are not much longer than 80 characters, you will not have any
  96.            problems.
  97.         A pattern will not cross lines.
  98.         If a line of the file is >256 characters or a line being replaced
  99.            is >256 ME will go down in flames.
  100.         [8] only works if the referenced tagged RE is made of constants and
  101.            case matters no matter what case-fold-search is set to. ie no
  102.            RE's here. Yes, pretty worthless and should be fixed.
  103.         Others, no doubt.
  104.