diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-07-07 08:36:28 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-07-07 08:36:28 (GMT) |
commit | 6d2896f5857feb78ad399b8167e50d970a9a5791 (patch) | |
tree | 39420f3450fa226c4f01916113938a72f9ec4228 /doc/regsub.n | |
parent | 53ca8c3c36eb3e91b418b65e588a601b017aa9dc (diff) | |
download | tcl-6d2896f5857feb78ad399b8167e50d970a9a5791.zip tcl-6d2896f5857feb78ad399b8167e50d970a9a5791.tar.gz tcl-6d2896f5857feb78ad399b8167e50d970a9a5791.tar.bz2 |
Correct examples. [Bug 1982642]
Diffstat (limited to 'doc/regsub.n')
-rw-r--r-- | doc/regsub.n | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/regsub.n b/doc/regsub.n index ca16aa8..413a6ab 100644 --- a/doc/regsub.n +++ b/doc/regsub.n @@ -6,7 +6,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.22 2007/12/13 15:22:33 dgp Exp $ +'\" RCS: @(#) $Id: regsub.n,v 1.22.2.1 2008/07/07 08:36:30 dkf Exp $ '\" .so man.macros .TH regsub n 8.3 Tcl "Tcl Built-In Commands" @@ -139,23 +139,30 @@ string after replacement is returned. See the manual entry for \fBregexp\fR for details on the interpretation of regular expressions. .SH EXAMPLES +.PP 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]]} @@ -170,4 +177,4 @@ regexp(n), re_syntax(n), subst(n), string(n) .VE .SH KEYWORDS -match, pattern, regular expression, substitute +match, pattern, quoting, regular expression, substitute |