summaryrefslogtreecommitdiffstats
path: root/doc/regsub.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-07-07 08:29:11 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-07-07 08:29:11 (GMT)
commit0e2831f23ba00afda87689a61956361bd7195b25 (patch)
tree63815c9fde2ab7529cdc556526ac2bfb8dc7238a /doc/regsub.n
parent8e8991e0652bcd5740d636df2dd001e91eca2803 (diff)
downloadtcl-0e2831f23ba00afda87689a61956361bd7195b25.zip
tcl-0e2831f23ba00afda87689a61956361bd7195b25.tar.gz
tcl-0e2831f23ba00afda87689a61956361bd7195b25.tar.bz2
Correct examples. [Bug 1982642]
Diffstat (limited to 'doc/regsub.n')
-rw-r--r--doc/regsub.n20
1 files changed, 13 insertions, 7 deletions
diff --git a/doc/regsub.n b/doc/regsub.n
index cc5994f..5686c1d 100644
--- a/doc/regsub.n
+++ b/doc/regsub.n
@@ -1,3 +1,4 @@
+'\" -*- nroff -*-
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -6,7 +7,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: regsub.n,v 1.23 2008/06/29 22:28:24 dkf Exp $
+'\" RCS: @(#) $Id: regsub.n,v 1.24 2008/07/07 08:29:14 dkf Exp $
'\"
.so man.macros
.TH regsub n 8.3 Tcl "Tcl Built-In Commands"
@@ -149,20 +150,26 @@ of regular expressions.
Replace (in the string in variable \fIstring\fR) every instance of
\fBfoo\fR which is a word by itself with \fBbar\fR:
.CS
-\fBregsub\fR -all {\e<foo\e>} $string bar string
+\fBregsub\fR -all {\emfoo\eM} $string bar string
+.CE
+or (using the
+.QW "basic regular expression"
+syntax):
+.CS
+\fBregsub\fR -all {(?b)\e<foo\e>} $string bar string
.CE
.PP
Insert double-quotes around the first instance of the word
\fBinteresting\fR, however it is capitalized.
.CS
-\fBregsub\fR -nocase {\e<interesting\e>} $string {"&"} string
+\fBregsub\fR -nocase {\eyinteresting\ey} $string {"&"} string
.CE
.PP
Convert all non-ASCII and Tcl-significant characters into \eu escape
sequences by using \fBregsub\fR and \fBsubst\fR in combination:
.CS
# This RE is just a character class for everything "bad"
-set RE {[][{};#\e\e\e$\es\eu0100-\euffff]}
+set RE {[][{};#\e\e\e$\es\eu0080-\euffff]}
# We will substitute with a fragment of Tcl script in brackets
set substitution {[format \e\e\e\eu%04x [scan "\e\e&" %c]]}
@@ -172,7 +179,6 @@ set substitution {[format \e\e\e\eu%04x [scan "\e\e&" %c]]}
set quoted [subst [\fBregsub\fR -all $RE $string $substitution]]
.CE
.SH "SEE ALSO"
-regexp(n), re_syntax(n), subst(n),
-string(n)
+regexp(n), re_syntax(n), subst(n), string(n)
.SH KEYWORDS
-match, pattern, regular expression, substitute
+match, pattern, quoting, regular expression, substitute