OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / CELLLINUX64 / util / CELLLINUX64 / man / mann / string.n
1 '\"
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.17.2.1 2003/04/11 20:49:53 dgp Exp $
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 5.5c 11c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH string n 8.1 Tcl "Tcl Built-In Commands"
247 .BS
248 '\" Note:  do not modify the .SH NAME line immediately below!
249 .SH NAME
250 string \- Manipulate strings
251 .SH SYNOPSIS
252 \fBstring \fIoption arg \fR?\fIarg ...?\fR
253 .BE
254
255 .SH DESCRIPTION
256 .PP
257 Performs one of several string operations, depending on \fIoption\fR.
258 The legal \fIoption\fRs (which may be abbreviated) are:
259 .TP
260 \fBstring bytelength \fIstring\fR
261 Returns a decimal string giving the number of bytes used to represent
262 \fIstring\fR in memory.  Because UTF\-8 uses one to three bytes to
263 represent Unicode characters, the byte length will not be the same as
264 the character length in general.  The cases where a script cares about
265 the byte length are rare.  In almost all cases, you should use the
266 \fBstring length\fR operation (including determining the length of a
267 Tcl ByteArray object).  Refer to the \fBTcl_NumUtfChars\fR manual
268 entry for more details on the UTF\-8 representation.
269 .TP
270 \fBstring compare\fR ?\fB\-nocase\fR? ?\fB\-length int\fR? \fIstring1 string2\fR
271 Perform a character-by-character comparison of strings \fIstring1\fR
272 and \fIstring2\fR.  Returns \-1, 0, or 1, depending on whether
273 \fIstring1\fR is lexicographically less than, equal to, or greater
274 than \fIstring2\fR.  If \fB\-length\fR is specified, then only the
275 first \fIlength\fR characters are used in the comparison.  If
276 \fB\-length\fR is negative, it is ignored.  If \fB\-nocase\fR is
277 specified, then the strings are compared in a case-insensitive manner.
278 .TP
279 \fBstring equal\fR ?\fB\-nocase\fR? ?\fB-length int\fR? \fIstring1 string2\fR
280 Perform a character-by-character comparison of strings \fIstring1\fR
281 and \fIstring2\fR.  Returns 1 if \fIstring1\fR and \fIstring2\fR are
282 identical, or 0 when not.  If \fB\-length\fR is specified, then only
283 the first \fIlength\fR characters are used in the comparison.  If
284 \fB\-length\fR is negative, it is ignored.  If \fB\-nocase\fR is
285 specified, then the strings are compared in a case-insensitive manner.
286 .TP
287 \fBstring first \fIstring1 string2\fR ?\fIstartIndex\fR?
288 Search \fIstring2\fR for a sequence of characters that exactly match
289 the characters in \fIstring1\fR.  If found, return the index of the
290 first character in the first such match within \fIstring2\fR.  If not
291 found, return \-1.  If \fIstartIndex\fR is specified (in any of the
292 forms accepted by the \fBindex\fR method), then the search is
293 constrained to start with the character in \fIstring2\fR specified by
294 the index.  For example,
295 .RS
296 .CS
297 \fBstring first a 0a23456789abcdef 5\fR
298 .CE
299 will return \fB10\fR, but
300 .CS
301 \fBstring first a 0123456789abcdef 11\fR
302 .CE
303 will return \fB\-1\fR.
304 .RE
305 .TP
306 \fBstring index \fIstring charIndex\fR
307 Returns the \fIcharIndex\fR'th character of the \fIstring\fR argument.
308 A \fIcharIndex\fR of 0 corresponds to the first character of the
309 string.  \fIcharIndex\fR may be specified as follows:
310 .RS
311 .IP \fIinteger\fR 10
312 The char specified at this integral index.
313 .IP \fBend\fR 10
314 The last char of the string.
315 .IP \fBend\-\fIinteger\fR 10
316 The last char of the string minus the specified integer offset
317 (e.g. \fBend\-1\fR would refer to the "c" in "abcd").
318 .PP
319 If \fIcharIndex\fR is less than 0 or greater than or equal to the
320 length of the string then an empty string is returned.
321 .RE
322 .TP
323 \fBstring is \fIclass\fR ?\fB\-strict\fR? ?\fB\-failindex \fIvarname\fR? \fIstring\fR
324 Returns 1 if \fIstring\fR is a valid member of the specified character
325 class, otherwise returns 0.  If \fB\-strict\fR is specified, then an
326 empty string returns 0, otherwise and empty string will return 1 on
327 any class.  If \fB\-failindex\fR is specified, then if the function
328 returns 0, the index in the string where the class was no longer valid
329 will be stored in the variable named \fIvarname\fR.  The \fIvarname\fR
330 will not be set if the function returns 1.  The following character
331 classes are recognized (the class name can be abbreviated):
332 .RS
333 .IP \fBalnum\fR 10
334 Any Unicode alphabet or digit character.
335 .IP \fBalpha\fR 10
336 Any Unicode alphabet character.
337 .IP \fBascii\fR 10
338 Any character with a value less than \\u0080 (those that are in the
339 7\-bit ascii range).
340 .IP \fBboolean\fR 10
341 Any of the forms allowed to \fBTcl_GetBoolean\fR.
342 .IP \fBcontrol\fR 10
343 Any Unicode control character.
344 .IP \fBdigit\fR 10
345 Any Unicode digit character.  Note that this includes characters
346 outside of the [0\-9] range.
347 .IP \fBdouble\fR 10
348 Any of the valid forms for a double in Tcl, with optional surrounding
349 whitespace.  In case of under/overflow in the value, 0 is returned and
350 the \fIvarname\fR will contain \-1.
351 .IP \fBfalse\fR 10
352 Any of the forms allowed to \fBTcl_GetBoolean\fR where the value is
353 false.
354 .IP \fBgraph\fR 10
355 Any Unicode printing character, except space.
356 .IP \fBinteger\fR 10
357 Any of the valid forms for a 32-bit integer in Tcl, with optional
358 surrounding whitespace.  In case of under/overflow in the value, 0 is
359 returned and the \fIvarname\fR will contain \-1.
360 .IP \fBlower\fR 10
361 Any Unicode lower case alphabet character.
362 .IP \fBprint\fR 10
363 Any Unicode printing character, including space.
364 .IP \fBpunct\fR 10
365 Any Unicode punctuation character.
366 .IP \fBspace\fR 10
367 Any Unicode space character.
368 .IP \fBtrue\fR 10
369 Any of the forms allowed to \fBTcl_GetBoolean\fR where the value is
370 true.
371 .IP \fBupper\fR 10
372 Any upper case alphabet character in the Unicode character set.
373 .IP \fBwordchar\fR 10
374 Any Unicode word character.  That is any alphanumeric character, and
375 any Unicode connector punctuation characters (e.g. underscore).
376 .IP \fBxdigit\fR 10
377 Any hexadecimal digit character ([0\-9A\-Fa\-f]).
378 .PP
379 In the case of \fBboolean\fR, \fBtrue\fR and \fBfalse\fR, if the
380 function will return 0, then the \fIvarname\fR will always be set to
381 0, due to the varied nature of a valid boolean value.
382 .RE
383 .TP
384 \fBstring last \fIstring1 string2\fR ?\fIlastIndex\fR?
385 Search \fIstring2\fR for a sequence of characters that exactly match
386 the characters in \fIstring1\fR.  If found, return the index of the
387 first character in the last such match within \fIstring2\fR.  If there
388 is no match, then return \-1.  If \fIlastIndex\fR is specified (in any
389 of the forms accepted by the \fBindex\fR method), then only the
390 characters in \fIstring2\fR at or before the specified \fIlastIndex\fR
391 will be considered by the search.  For example,
392 .RS
393 .CS
394 \fBstring last a 0a23456789abcdef 15\fR
395 .CE
396 will return \fB10\fR, but
397 .CS
398 \fBstring last a 0a23456789abcdef 9\fR
399 .CE
400 will return \fB1\fR.
401 .RE
402 .TP
403 \fBstring length \fIstring\fR
404 Returns a decimal string giving the number of characters in
405 \fIstring\fR.  Note that this is not necessarily the same as the
406 number of bytes used to store the string.  If the object is a
407 ByteArray object (such as those returned from reading a binary encoded
408 channel), then this will return the actual byte length of the object.
409 .TP
410 \fBstring map\fR ?\fB\-nocase\fR? \fIcharMap string\fR
411 Replaces characters in \fIstring\fR based on the key-value pairs in
412 \fIcharMap\fR.  \fIcharMap\fR is a list of \fIkey value key value ...\fR
413 as in the form returned by \fBarray get\fR.  Each instance of a
414 key in the string will be replaced with its corresponding value.  If
415 \fB\-nocase\fR is specified, then matching is done without regard to
416 case differences. Both \fIkey\fR and \fIvalue\fR may be multiple
417 characters.  Replacement is done in an ordered manner, so the key
418 appearing first in the list will be checked first, and so on.
419 \fIstring\fR is only iterated over once, so earlier key replacements
420 will have no affect for later key matches.  For example,
421 .RS
422 .CS
423 \fBstring map {abc 1 ab 2 a 3 1 0} 1abcaababcabababc\fR
424 .CE
425 will return the string \fB01321221\fR.
426 .RE
427 .TP
428 \fBstring match\fR ?\fB\-nocase\fR? \fIpattern\fR \fIstring\fR
429 See if \fIpattern\fR matches \fIstring\fR; return 1 if it does, 0 if
430 it doesn't.  If \fB\-nocase\fR is specified, then the pattern attempts
431 to match against the string in a case insensitive manner.  For the two
432 strings to match, their contents must be identical except that the
433 following special sequences may appear in \fIpattern\fR:
434 .RS
435 .IP \fB*\fR 10
436 Matches any sequence of characters in \fIstring\fR, including a null
437 string.
438 .IP \fB?\fR 10
439 Matches any single character in \fIstring\fR.
440 .IP \fB[\fIchars\fB]\fR 10
441 Matches any character in the set given by \fIchars\fR.  If a sequence
442 of the form \fIx\fB\-\fIy\fR appears in \fIchars\fR, then any
443 character between \fIx\fR and \fIy\fR, inclusive, will match.  When
444 used with \fB\-nocase\fR, the end points of the range are converted to
445 lower case first.  Whereas {[A\-z]} matches '_' when matching
446 case-sensitively ('_' falls between the 'Z' and 'a'), with
447 \fB\-nocase\fR this is considered like {[A\-Za\-z]} (and probably what
448 was meant in the first place).
449 .IP \fB\e\fIx\fR 10
450 Matches the single character \fIx\fR.  This provides a way of avoiding
451 the special interpretation of the characters \fB*?[]\e\fR in
452 \fIpattern\fR.
453 .RE
454 .TP
455 \fBstring range \fIstring first last\fR
456 Returns a range of consecutive characters from \fIstring\fR, starting
457 with the character whose index is \fIfirst\fR and ending with the
458 character whose index is \fIlast\fR. An index of 0 refers to the first
459 character of the string.  \fIfirst\fR and \fIlast\fR may be specified
460 as for the \fBindex\fR method.  If \fIfirst\fR is less than zero then
461 it is treated as if it were zero, and if \fIlast\fR is greater than or
462 equal to the length of the string then it is treated as if it were
463 \fBend\fR.  If \fIfirst\fR is greater than \fIlast\fR then an empty
464 string is returned.
465 .TP
466 \fBstring repeat \fIstring count\fR
467 Returns \fIstring\fR repeated \fIcount\fR number of times.
468 .TP
469 \fBstring replace \fIstring first last\fR ?\fInewstring\fR?
470 Removes a range of consecutive characters from \fIstring\fR, starting
471 with the character whose index is \fIfirst\fR and ending with the
472 character whose index is \fIlast\fR.  An index of 0 refers to the
473 first character of the string.  \fIFirst\fR and \fIlast\fR may be
474 specified as for the \fBindex\fR method.  If \fInewstring\fR is
475 specified, then it is placed in the removed character range.  If
476 \fIfirst\fR is less than zero then it is treated as if it were zero,
477 and if \fIlast\fR is greater than or equal to the length of the string
478 then it is treated as if it were \fBend\fR.  If \fIfirst\fR is greater
479 than \fIlast\fR or the length of the initial string, or \fIlast\fR is
480 less than 0, then the initial string is returned untouched.
481 .TP
482 \fBstring tolower \fIstring\fR ?\fIfirst\fR? ?\fIlast\fR?
483 Returns a value equal to \fIstring\fR except that all upper (or title)
484 case letters have been converted to lower case.  If \fIfirst\fR is
485 specified, it refers to the first char index in the string to start
486 modifying.  If \fIlast\fR is specified, it refers to the char index in
487 the string to stop at (inclusive).  \fIfirst\fR and \fIlast\fR may be
488 specified as for the \fBindex\fR method.
489 .TP
490 \fBstring totitle \fIstring\fR ?\fIfirst\fR? ?\fIlast\fR?
491 Returns a value equal to \fIstring\fR except that the first character
492 in \fIstring\fR is converted to its Unicode title case variant (or
493 upper case if there is no title case variant) and the rest of the
494 string is converted to lower case.  If \fIfirst\fR is specified, it
495 refers to the first char index in the string to start modifying.  If
496 \fIlast\fR is specified, it refers to the char index in the string to
497 stop at (inclusive).  \fIfirst\fR and \fIlast\fR may be specified as
498 for the \fBindex\fR method.
499 .TP
500 \fBstring toupper \fIstring\fR ?\fIfirst\fR? ?\fIlast\fR?
501 Returns a value equal to \fIstring\fR except that all lower (or title)
502 case letters have been converted to upper case.  If \fIfirst\fR is
503 specified, it refers to the first char index in the string to start
504 modifying.  If \fIlast\fR is specified, it refers to the char index in
505 the string to stop at (inclusive).  \fIfirst\fR and \fIlast\fR may be
506 specified as for the \fBindex\fR method.
507 .TP
508 \fBstring trim \fIstring\fR ?\fIchars\fR?
509 Returns a value equal to \fIstring\fR except that any leading or
510 trailing characters from the set given by \fIchars\fR are removed.  If
511 \fIchars\fR is not specified then white space is removed (spaces,
512 tabs, newlines, and carriage returns).
513 .TP
514 \fBstring trimleft \fIstring\fR ?\fIchars\fR?
515 Returns a value equal to \fIstring\fR except that any leading
516 characters from the set given by \fIchars\fR are removed.  If
517 \fIchars\fR is not specified then white space is removed (spaces,
518 tabs, newlines, and carriage returns).
519 .TP
520 \fBstring trimright \fIstring\fR ?\fIchars\fR?
521 Returns a value equal to \fIstring\fR except that any trailing
522 characters from the set given by \fIchars\fR are removed.  If
523 \fIchars\fR is not specified then white space is removed (spaces,
524 tabs, newlines, and carriage returns).
525 .TP
526 \fBstring wordend \fIstring charIndex\fR
527 Returns the index of the character just after the last one in the word
528 containing character \fIcharIndex\fR of \fIstring\fR.  \fIcharIndex\fR
529 may be specified as for the \fBindex\fR method.  A word is
530 considered to be any contiguous range of alphanumeric (Unicode letters
531 or decimal digits) or underscore (Unicode connector punctuation)
532 characters, or any single character other than these.
533 .TP
534 \fBstring wordstart \fIstring charIndex\fR
535 Returns the index of the first character in the word containing
536 character \fIcharIndex\fR of \fIstring\fR.  \fIcharIndex\fR may be
537 specified as for the \fBindex\fR method.  A word is considered to be any
538 contiguous range of alphanumeric (Unicode letters or decimal digits)
539 or underscore (Unicode connector punctuation) characters, or any
540 single character other than these.
541
542 .SH "SEE ALSO"
543 expr(n), list(n)
544
545 .SH KEYWORDS
546 case conversion, compare, index, match, pattern, string, word, equal, ctype