summaryrefslogtreecommitdiffstats
path: root/doc/regsub.n
diff options
context:
space:
mode:
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