home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Libraries / tcl7.4b3 / doc / regsub.n < prev    next >
Encoding:
Text File  |  1994-12-17  |  2.7 KB  |  79 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" Copyright (c) 1994 Sun Microsystems, Inc.
  4. '\"
  5. '\" See the file "license.terms" for information on usage and redistribution
  6. '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '\" 
  8. '\" @(#) regsub.n 1.4 94/12/17 16:18:42
  9. '\" 
  10. .so man.macros
  11. .HS regsub tcl 7.4
  12. .BS
  13. '\" Note:  do not modify the .SH NAME line immediately below!
  14. .SH NAME
  15. regsub \- Perform substitutions based on regular expression pattern matching
  16. .SH SYNOPSIS
  17. \fBregsub \fR?\fIswitches\fR? \fIexp string subSpec varName\fR
  18. .BE
  19.  
  20. .SH DESCRIPTION
  21. .PP
  22. This command matches the regular expression \fIexp\fR against
  23. \fIstring\fR,
  24. .VS
  25. and it copies \fIstring\fR to the variable whose name is
  26. given by \fIvarName\fR.
  27. If there is a match, then while copying \fIstring\fR to \fIvarName\fR
  28. the portion of \fIstring\fR that
  29. .VE
  30. matched \fIexp\fR is replaced with \fIsubSpec\fR.
  31. If \fIsubSpec\fR contains a ``&'' or ``\e0'', then it is replaced
  32. in the substitution with the portion of \fIstring\fR that
  33. matched \fIexp\fR.
  34. If \fIsubSpec\fR contains a ``\e\fIn\fR'', where \fIn\fR is a digit
  35. between 1 and 9, then it is replaced in the substitution with
  36. the portion of \fIstring\fR that matched the \fIn\fR-th
  37. parenthesized subexpression of \fIexp\fR.
  38. Additional backslashes may be used in \fIsubSpec\fR to prevent special
  39. interpretation of ``&'' or ``\e0'' or ``\e\fIn\fR'' or
  40. backslash.
  41. The use of backslashes in \fIsubSpec\fR tends to interact badly
  42. with the Tcl parser's use of backslashes, so it's generally
  43. safest to enclose \fIsubSpec\fR in braces if it includes
  44. backslashes.
  45. .LP
  46. If the initial arguments to \fBregexp\fR start with \fB\-\fR then
  47. .VS
  48. they are treated as switches.  The following switches are
  49. currently supported:
  50. .TP 10
  51. \fB\-all\fR
  52. All ranges in \fIstring\fR that match \fIexp\fR are found and
  53. substitution is performed for each of these ranges.
  54. Without this switch only the first
  55. matching range is found and substituted.
  56. If \fB\-all\fR is specified, then ``&'' and ``\e\fIn\fR''
  57. sequences are handled for each substitution using the information
  58. from the corresponding match.
  59. .TP 10
  60. \fB\-nocase\fR
  61. Upper-case characters in \fIstring\fR will be converted to lower-case
  62. before matching against \fIexp\fR;  however, substitutions specified
  63. by \fIsubSpec\fR use the original unconverted form of \fIstring\fR.
  64. .TP 10
  65. \fB\-\|\-\fR
  66. Marks the end of switches.  The argument following this one will
  67. be treated as \fIexp\fR even if it starts with a \fB\-.
  68. .VE
  69. .PP
  70. .VS
  71. The command returns a count of the number of matching ranges that
  72. were found and replaced.
  73. .VE
  74. See the manual entry for \fBregexp\fR for details on the interpretation
  75. of regular expressions.
  76.  
  77. .SH KEYWORDS
  78. match, pattern, regular expression, substitute
  79.