📄 regsub.n
字号:
'\"'\" Copyright (c) 1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) regsub.n 1.9 96/08/26 13:00:11'\" .so man.macros.TH regsub n 7.4 Tcl "Tcl Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEregsub \- Perform substitutions based on regular expression pattern matching.SH SYNOPSIS\fBregsub \fR?\fIswitches\fR? \fIexp string subSpec varName\fR.BE.SH DESCRIPTION.PPThis command matches the regular expression \fIexp\fR against\fIstring\fR,and it copies \fIstring\fR to the variable whose name isgiven by \fIvarName\fR.If there is a match, then while copying \fIstring\fR to \fIvarName\fRthe portion of \fIstring\fR thatmatched \fIexp\fR is replaced with \fIsubSpec\fR.If \fIsubSpec\fR contains a ``&'' or ``\e0'', then it is replacedin the substitution with the portion of \fIstring\fR thatmatched \fIexp\fR.If \fIsubSpec\fR contains a ``\e\fIn\fR'', where \fIn\fR is a digitbetween 1 and 9, then it is replaced in the substitution withthe portion of \fIstring\fR that matched the \fIn\fR-thparenthesized subexpression of \fIexp\fR.Additional backslashes may be used in \fIsubSpec\fR to prevent specialinterpretation of ``&'' or ``\e0'' or ``\e\fIn\fR'' orbackslash.The use of backslashes in \fIsubSpec\fR tends to interact badlywith the Tcl parser's use of backslashes, so it's generallysafest to enclose \fIsubSpec\fR in braces if it includesbackslashes..LPIf the initial arguments to \fBregexp\fR start with \fB\-\fR thenthey are treated as switches. The following switches arecurrently supported:.TP 10\fB\-all\fRAll ranges in \fIstring\fR that match \fIexp\fR are found andsubstitution is performed for each of these ranges.Without this switch only the firstmatching range is found and substituted.If \fB\-all\fR is specified, then ``&'' and ``\e\fIn\fR''sequences are handled for each substitution using the informationfrom the corresponding match..TP 10\fB\-nocase\fRUpper-case characters in \fIstring\fR will be converted to lower-casebefore matching against \fIexp\fR; however, substitutions specifiedby \fIsubSpec\fR use the original unconverted form of \fIstring\fR..TP 10\fB\-\|\-\fRMarks the end of switches. The argument following this one willbe treated as \fIexp\fR even if it starts with a \fB\-\fR..PPThe command returns a count of the number of matching ranges thatwere found and replaced.See the manual entry for \fBregexp\fR for details on the interpretationof regular expressions..SH KEYWORDSmatch, pattern, regular expression, substitute
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -