home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / strings / regsub < prev    next >
Encoding:
Text File  |  1993-10-26  |  2.5 KB  |  51 lines  |  [TEXT/$Tcl]

  1.  
  2.           regsub ?switches? exp string subSpec varName
  3.  
  4.  
  5.      DESCRIPTION
  6.           This command matches  the  regular  expression  exp  against
  7.           string,  and  it copies string to the variable whose name is
  8.           given by varName.  The command returns 1 if there is a match
  9.           and 0 if there isn't.  If there is a match, then while copy-
  10.           ing string to varName the portion of string that matched exp
  11.           is  replaced  with  subSpec.  If subSpec contains a ``&'' or
  12.           ``\0'', then it is replaced in  the  substitution  with  the
  13.           portion  of  string that matched exp.  If subSpec contains a
  14.           ``\n'', where n is a digit between  1  and  9,  then  it  is
  15.           replaced in the substitution with the portion of string that
  16.           matched the n-th parenthesized subexpression of exp.   Addi-
  17.           tional backslashes may be used in subSpec to prevent special
  18.           interpretation of ``&'' or ``\0'' or  ``\n''  or  backslash.
  19.           The  use  of  backslashes in subSpec tends to interact badly
  20.           with the Tcl parser's use of backslashes, so it's  generally
  21.           safest   to   enclose  subSpec  in  braces  if  it  includes
  22.           backslashes.
  23.  
  24.           If the initial arguments to regexp start with  -  then  they
  25.           are   treated  as  switches.   The  following  switches  are
  26.           currently supported:
  27.  
  28.           -all      All ranges in string that match exp are found  and
  29.                     substitution   is  performed  for  each  of  these
  30.                     ranges.  Without this switch only the first match-
  31.                     ing  range  is  found and substituted.  If -all is
  32.                     specified, then ``&''  and  ``\n''  sequences  are
  33.                     handled  for  each substitution using the informa-
  34.                     tion from the corresponding match.
  35.  
  36.           -nocase   Upper-case characters in string will be  converted
  37.                     to  lower-case  before matching against exp;  how-
  38.                     ever, substitutions specified by subSpec  use  the
  39.                     original unconverted form of string.
  40.  
  41.           --        Marks the end of switches.  The argument following
  42.                     this  one will be treated as exp even if it starts
  43.                     with a -.
  44.  
  45.           See the manual entry for regexp for details on the interpre-
  46.           tation of regular expressions.
  47.  
  48.  
  49.      KEYWORDS
  50.           match, pattern, regular expression, substitute
  51.