| 1 | 578 | markom | '\"
 | 
      
         | 2 |  |  | '\" Copyright (c) 1993 The Regents of the University of California.
 | 
      
         | 3 |  |  | '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
 | 
      
         | 4 |  |  | '\"
 | 
      
         | 5 |  |  | '\" See the file "license.terms" for information on usage and redistribution
 | 
      
         | 6 |  |  | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 | 
      
         | 7 |  |  | '\"
 | 
      
         | 8 |  |  | '\" RCS: @(#) $Id: string.n,v 1.1.1.1 2002-01-16 10:25:25 markom Exp $
 | 
      
         | 9 |  |  | '\"
 | 
      
         | 10 |  |  | .so man.macros
 | 
      
         | 11 |  |  | .TH string n 7.6 Tcl "Tcl Built-In Commands"
 | 
      
         | 12 |  |  | .BS
 | 
      
         | 13 |  |  | '\" Note:  do not modify the .SH NAME line immediately below!
 | 
      
         | 14 |  |  | .SH NAME
 | 
      
         | 15 |  |  | string \- Manipulate strings
 | 
      
         | 16 |  |  | .SH SYNOPSIS
 | 
      
         | 17 |  |  | \fBstring \fIoption arg \fR?\fIarg ...?\fR
 | 
      
         | 18 |  |  | .BE
 | 
      
         | 19 |  |  |  
 | 
      
         | 20 |  |  | .SH DESCRIPTION
 | 
      
         | 21 |  |  | .PP
 | 
      
         | 22 |  |  | Performs one of several string operations, depending on \fIoption\fR.
 | 
      
         | 23 |  |  | The legal \fIoption\fRs (which may be abbreviated) are:
 | 
      
         | 24 |  |  | .TP
 | 
      
         | 25 |  |  | \fBstring compare \fIstring1 string2\fR
 | 
      
         | 26 |  |  | Perform a character-by-character comparison of strings \fIstring1\fR and
 | 
      
         | 27 |  |  | \fIstring2\fR in the same way as the C \fBstrcmp\fR procedure.  Return
 | 
      
         | 28 |  |  | \-1, 0, or 1, depending on whether \fIstring1\fR is lexicographically
 | 
      
         | 29 |  |  | less than, equal to, or greater than \fIstring2\fR.
 | 
      
         | 30 |  |  | .TP
 | 
      
         | 31 |  |  | \fBstring first \fIstring1 string2\fR
 | 
      
         | 32 |  |  | Search \fIstring2\fR for a sequence of characters that exactly match
 | 
      
         | 33 |  |  | the characters in \fIstring1\fR.  If found, return the index of the
 | 
      
         | 34 |  |  | first character in the first such match within \fIstring2\fR.  If not
 | 
      
         | 35 |  |  | found, return \-1.
 | 
      
         | 36 |  |  | .TP
 | 
      
         | 37 |  |  | \fBstring index \fIstring charIndex\fR
 | 
      
         | 38 |  |  | Returns the \fIcharIndex\fR'th character of the \fIstring\fR
 | 
      
         | 39 |  |  | argument.  A \fIcharIndex\fR of 0 corresponds to the first
 | 
      
         | 40 |  |  | character of the string.
 | 
      
         | 41 |  |  | If \fIcharIndex\fR is less than 0 or greater than
 | 
      
         | 42 |  |  | or equal to the length of the string then an empty string is
 | 
      
         | 43 |  |  | returned.
 | 
      
         | 44 |  |  | .TP
 | 
      
         | 45 |  |  | \fBstring last \fIstring1 string2\fR
 | 
      
         | 46 |  |  | Search \fIstring2\fR for a sequence of characters that exactly match
 | 
      
         | 47 |  |  | the characters in \fIstring1\fR.  If found, return the index of the
 | 
      
         | 48 |  |  | first character in the last such match within \fIstring2\fR.  If there
 | 
      
         | 49 |  |  | is no match, then return \-1.
 | 
      
         | 50 |  |  | .TP
 | 
      
         | 51 |  |  | \fBstring length \fIstring\fR
 | 
      
         | 52 |  |  | Returns a decimal string giving the number of characters in \fIstring\fR.
 | 
      
         | 53 |  |  | .TP
 | 
      
         | 54 |  |  | \fBstring match \fIpattern\fR \fIstring\fR
 | 
      
         | 55 |  |  | See if \fIpattern\fR matches \fIstring\fR; return 1 if it does, 0
 | 
      
         | 56 |  |  | if it doesn't.  Matching is done in a fashion similar to that
 | 
      
         | 57 |  |  | used by the C-shell.  For the two strings to match, their contents
 | 
      
         | 58 |  |  | must be identical except that the following special sequences
 | 
      
         | 59 |  |  | may appear in \fIpattern\fR:
 | 
      
         | 60 |  |  | .RS
 | 
      
         | 61 |  |  | .IP \fB*\fR 10
 | 
      
         | 62 |  |  | Matches any sequence of characters in \fIstring\fR,
 | 
      
         | 63 |  |  | including a null string.
 | 
      
         | 64 |  |  | .IP \fB?\fR 10
 | 
      
         | 65 |  |  | Matches any single character in \fIstring\fR.
 | 
      
         | 66 |  |  | .IP \fB[\fIchars\fB]\fR 10
 | 
      
         | 67 |  |  | Matches any character in the set given by \fIchars\fR.  If a sequence
 | 
      
         | 68 |  |  | of the form
 | 
      
         | 69 |  |  | \fIx\fB\-\fIy\fR appears in \fIchars\fR, then any character
 | 
      
         | 70 |  |  | between \fIx\fR and \fIy\fR, inclusive, will match.
 | 
      
         | 71 |  |  | .IP \fB\e\fIx\fR 10
 | 
      
         | 72 |  |  | Matches the single character \fIx\fR.  This provides a way of
 | 
      
         | 73 |  |  | avoiding the special interpretation of the characters
 | 
      
         | 74 |  |  | \fB*?[]\e\fR in \fIpattern\fR.
 | 
      
         | 75 |  |  | .RE
 | 
      
         | 76 |  |  | .TP
 | 
      
         | 77 |  |  | \fBstring range \fIstring first last\fR
 | 
      
         | 78 |  |  | Returns a range of consecutive characters from \fIstring\fR, starting
 | 
      
         | 79 |  |  | with the character whose index is \fIfirst\fR and ending with the
 | 
      
         | 80 |  |  | character whose index is \fIlast\fR. An index of 0 refers to the
 | 
      
         | 81 |  |  | first character of the string.
 | 
      
         | 82 |  |  | An index of \fBend\fR (or any
 | 
      
         | 83 |  |  | abbreviation of it) refers to the last character of the string.
 | 
      
         | 84 |  |  | If \fIfirst\fR is less than zero then it is treated as if it were zero, and
 | 
      
         | 85 |  |  | if \fIlast\fR is greater than or equal to the length of the string then
 | 
      
         | 86 |  |  | it is treated as if it were \fBend\fR.  If \fIfirst\fR is greater than
 | 
      
         | 87 |  |  | \fIlast\fR then an empty string is returned.
 | 
      
         | 88 |  |  | .TP
 | 
      
         | 89 |  |  | \fBstring tolower \fIstring\fR
 | 
      
         | 90 |  |  | Returns a value equal to \fIstring\fR except that all upper case
 | 
      
         | 91 |  |  | letters have been converted to lower case.
 | 
      
         | 92 |  |  | .TP
 | 
      
         | 93 |  |  | \fBstring toupper \fIstring\fR
 | 
      
         | 94 |  |  | Returns a value equal to \fIstring\fR except that all lower case
 | 
      
         | 95 |  |  | letters have been converted to upper case.
 | 
      
         | 96 |  |  | .TP
 | 
      
         | 97 |  |  | \fBstring trim \fIstring\fR ?\fIchars\fR?
 | 
      
         | 98 |  |  | Returns a value equal to \fIstring\fR except that any leading
 | 
      
         | 99 |  |  | or trailing characters from the set given by \fIchars\fR are
 | 
      
         | 100 |  |  | removed.
 | 
      
         | 101 |  |  | If \fIchars\fR is not specified then white space is removed
 | 
      
         | 102 |  |  | (spaces, tabs, newlines, and carriage returns).
 | 
      
         | 103 |  |  | .TP
 | 
      
         | 104 |  |  | \fBstring trimleft \fIstring\fR ?\fIchars\fR?
 | 
      
         | 105 |  |  | Returns a value equal to \fIstring\fR except that any
 | 
      
         | 106 |  |  | leading characters from the set given by \fIchars\fR are
 | 
      
         | 107 |  |  | removed.
 | 
      
         | 108 |  |  | If \fIchars\fR is not specified then white space is removed
 | 
      
         | 109 |  |  | (spaces, tabs, newlines, and carriage returns).
 | 
      
         | 110 |  |  | .TP
 | 
      
         | 111 |  |  | \fBstring trimright \fIstring\fR ?\fIchars\fR?
 | 
      
         | 112 |  |  | Returns a value equal to \fIstring\fR except that any
 | 
      
         | 113 |  |  | trailing characters from the set given by \fIchars\fR are
 | 
      
         | 114 |  |  | removed.
 | 
      
         | 115 |  |  | If \fIchars\fR is not specified then white space is removed
 | 
      
         | 116 |  |  | (spaces, tabs, newlines, and carriage returns).
 | 
      
         | 117 |  |  | .TP
 | 
      
         | 118 |  |  | \fBstring wordend \fIstring index\fR
 | 
      
         | 119 |  |  | Returns the index of the character just after the last one in the
 | 
      
         | 120 |  |  | word containing character \fIindex\fR of \fIstring\fR.
 | 
      
         | 121 |  |  | A word is considered to be any contiguous range of alphanumeric
 | 
      
         | 122 |  |  | or underscore characters, or any single character other than these.
 | 
      
         | 123 |  |  | .TP
 | 
      
         | 124 |  |  | \fBstring wordstart \fIstring index\fR
 | 
      
         | 125 |  |  | Returns the index of the first character in the
 | 
      
         | 126 |  |  | word containing character \fIindex\fR of \fIstring\fR.
 | 
      
         | 127 |  |  | A word is considered to be any contiguous range of alphanumeric
 | 
      
         | 128 |  |  | or underscore characters, or any single character other than these.
 | 
      
         | 129 |  |  |  
 | 
      
         | 130 |  |  | .SH KEYWORDS
 | 
      
         | 131 |  |  | case conversion, compare, index, match, pattern, string, word
 |