home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / me_cd25.zip / DOC.ZIP / REGEXP.DOC < prev    next >
Text File  |  1992-11-09  |  5KB  |  115 lines

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