📄 string.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: @(#) string.n 1.9 96/08/26 13:00:14'\" .so man.macros.TH string n 7.6 Tcl "Tcl Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEstring \- Manipulate strings.SH SYNOPSIS\fBstring \fIoption arg \fR?\fIarg ...?\fR.BE.SH DESCRIPTION.PPPerforms one of several string operations, depending on \fIoption\fR.The legal \fIoption\fRs (which may be abbreviated) are:.TP\fBstring compare \fIstring1 string2\fRPerform a character-by-character comparison of strings \fIstring1\fR and\fIstring2\fR in the same way as the C \fBstrcmp\fR procedure. Return\-1, 0, or 1, depending on whether \fIstring1\fR is lexicographicallyless than, equal to, or greater than \fIstring2\fR..TP\fBstring first \fIstring1 string2\fRSearch \fIstring2\fR for a sequence of characters that exactly matchthe characters in \fIstring1\fR. If found, return the index of thefirst character in the first such match within \fIstring2\fR. If notfound, return \-1..TP\fBstring index \fIstring charIndex\fRReturns the \fIcharIndex\fR'th character of the \fIstring\fRargument. A \fIcharIndex\fR of 0 corresponds to the firstcharacter of the string.If \fIcharIndex\fR is less than 0 or greater thanor equal to the length of the string then an empty string isreturned..TP\fBstring last \fIstring1 string2\fRSearch \fIstring2\fR for a sequence of characters that exactly matchthe characters in \fIstring1\fR. If found, return the index of thefirst character in the last such match within \fIstring2\fR. If thereis no match, then return \-1..TP\fBstring length \fIstring\fRReturns a decimal string giving the number of characters in \fIstring\fR..TP\fBstring match \fIpattern\fR \fIstring\fRSee if \fIpattern\fR matches \fIstring\fR; return 1 if it does, 0if it doesn't. Matching is done in a fashion similar to thatused by the C-shell. For the two strings to match, their contentsmust be identical except that the following special sequencesmay appear in \fIpattern\fR:.RS.IP \fB*\fR 10Matches any sequence of characters in \fIstring\fR,including a null string..IP \fB?\fR 10Matches any single character in \fIstring\fR..IP \fB[\fIchars\fB]\fR 10Matches any character in the set given by \fIchars\fR. If a sequenceof the form\fIx\fB\-\fIy\fR appears in \fIchars\fR, then any characterbetween \fIx\fR and \fIy\fR, inclusive, will match..IP \fB\e\fIx\fR 10Matches the single character \fIx\fR. This provides a way ofavoiding the special interpretation of the characters\fB*?[]\e\fR in \fIpattern\fR..RE.TP\fBstring range \fIstring first last\fRReturns a range of consecutive characters from \fIstring\fR, startingwith the character whose index is \fIfirst\fR and ending with thecharacter whose index is \fIlast\fR. An index of 0 refers to thefirst character of the string. An index of \fBend\fR (or anyabbreviation of it) refers to the last character of the string.If \fIfirst\fR is less than zero then it is treated as if it were zero, andif \fIlast\fR is greater than or equal to the length of the string thenit is treated as if it were \fBend\fR. If \fIfirst\fR is greater than\fIlast\fR then an empty string is returned..TP\fBstring tolower \fIstring\fRReturns a value equal to \fIstring\fR except that all upper caseletters have been converted to lower case..TP\fBstring toupper \fIstring\fRReturns a value equal to \fIstring\fR except that all lower caseletters have been converted to upper case..TP\fBstring trim \fIstring\fR ?\fIchars\fR?Returns a value equal to \fIstring\fR except that any leadingor trailing characters from the set given by \fIchars\fR areremoved.If \fIchars\fR is not specified then white space is removed(spaces, tabs, newlines, and carriage returns)..TP\fBstring trimleft \fIstring\fR ?\fIchars\fR?Returns a value equal to \fIstring\fR except that anyleading characters from the set given by \fIchars\fR areremoved.If \fIchars\fR is not specified then white space is removed(spaces, tabs, newlines, and carriage returns)..TP\fBstring trimright \fIstring\fR ?\fIchars\fR?Returns a value equal to \fIstring\fR except that anytrailing characters from the set given by \fIchars\fR areremoved.If \fIchars\fR is not specified then white space is removed(spaces, tabs, newlines, and carriage returns)..TP\fBstring wordend \fIstring index\fRReturns the index of the character just after the last one in theword containing character \fIindex\fR of \fIstring\fR.A word is considered to be any contiguous range of alphanumericor underscore characters, or any single character other than these..TP\fBstring wordstart \fIstring index\fRReturns the index of the first character in theword containing character \fIindex\fR of \fIstring\fR.A word is considered to be any contiguous range of alphanumericor underscore characters, or any single character other than these..SH KEYWORDScase conversion, compare, index, match, pattern, string, word
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -