Tcl Source Code

Check-in [c11222b967]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Rewrite the documentation of [regsub -command] so it's not quite such a mess.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c11222b967f3c6518b415bc0a9644f5777b4972d
User & Date: dgp 2017-06-23 13:09:23
Context
2017-06-23
13:11
typo fix check-in: b3af99ceb9 user: dgp tags: trunk
13:09
Rewrite the documentation of [regsub -command] so it's not quite such a mess. check-in: c11222b967 user: dgp tags: trunk
12:39
repair broken tests check-in: b063408c38 user: dgp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/regsub.n.

66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81


82
83
84

85
86
87
88
89
90
91
and
.QW \e\fIn\fR
sequences are handled for each substitution using the information
from the corresponding match.
.TP
\fB\-command\fR
.VS 8.7
Changes the handling of the substitution string so that it no longer treats

.QW &
and
.QW \e
as special characters, but instead uses them as a non-empty list of words.
Each time a substitution is processed, another complete Tcl word is appended
to that list for each substitution value (the first such argument represents
the overall matched substring, the subsequent arguments will be one per
capturing sub-RE, much as are returned from \fBregexp\fR \fB\-inline\fR) and


the overall list is then evaluated as a Tcl command call. If the command
finishes successfully, the result of command call is substituted into the
resulting string.

.RS
.PP
If \fB\-all\fR is not also given, the command callback will be invoked at most
once (exactly when the regular expression matches). If \fB\-all\fR is given,
the command callback will be invoked for each matched location, in sequence.
The exact location indices that matched are not made available to the script.
.PP







|
>


|
|
<
|
|
|
>
>
|
<
|
>







66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
and
.QW \e\fIn\fR
sequences are handled for each substitution using the information
from the corresponding match.
.TP
\fB\-command\fR
.VS 8.7
Changes the handling of \fIsubSpec\fR so that it is not treated
as a template for a substitution string and the substrings
.QW &
and
.QW \e\fIn\fR
no longer have special meaning. Instead \fIsubSpec\fR must be a

command prefix, that is, a non-empty list.  The substring of \fIstring\fR
that matches \fIexp\fR, and then each substring that matches each
capturing sub-RE within \fIexp\fR are appended as additional elements
to that list. (The items appended to the list are much like what
\fBregexp\fR \fB-inline\fR would return).  The completed list is then
evaluated as a Tcl command, and the result of that command is the

substitution string.  Any error or exception from command evaluation
becomes an error or exception from the \fBregsub\fR command.
.RS
.PP
If \fB\-all\fR is not also given, the command callback will be invoked at most
once (exactly when the regular expression matches). If \fB\-all\fR is given,
the command callback will be invoked for each matched location, in sequence.
The exact location indices that matched are not made available to the script.
.PP