projman/hlp/ru/tcl/string.html
2015-10-19 14:27:31 +04:00

188 lines
7.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>string</title>
</head>
<body>
<h1>string</h1>
<p>ëÏÍÁÎÄÁ ÄÌÑ ÒÁÂÏÔÙ ÓÏ ÓÔÒÏËÁÍÉ.</p>
<h2>óéîôáëóéó</h2>
<pre>
<strong>string</strong> <strong>option</strong> <em>arg</em> ?<em>arg</em>...?
</pre>
<h2>ïðéóáîéå</h2>
<p>÷ÙÐÏÌÎÑÅÔ ÏÄÎÕ ÉÚ ÐÅÒÅÞÉÓÌÅÎÎÙÈ ÎÉÖÅ ÓÔÒÏËÏ×ÙÈ ÏÐÅÒÁÃÉÊ ×
ÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÚÁÄÁÎÎÏÊ ÏÐÃÉÉ <em>option</em>.</p>
<dl>
<dt><a name="string compare"></a><strong>string</strong> <strong>compare</strong>
<em>string1</em> <em>string2</em></dt>
<dd>÷ÙÐÏÌÎÑÅÔ ÐÏÓÉÍ×ÏÌØÎÏÅ ÓÒÁ×ÎÅÎÉÅ ÓÔÒÏË <em>string1</em> É <em>
string2</em> ÔÁË ÖÅ, ËÁË ó-ÐÒÏÃÅÄÕÒÁ <strong>strcmp</strong>. ÷ÏÚ×ÒÁÝÁÅÔ
<strong>-1, 0</strong> ÉÌÉ <strong>1</strong>, × ÚÁ×ÉÓÉÍÏÓÔÉ ÏÔ ÔÏÇÏ, ÂÕÄÅÔ ÌÉ
ÓÔÒÏËÁ <em>string1</em> ÂÏÌØÛÅ, ÒÁ×ÎÁ ÉÌÉ ÍÅÎØÛÅ (ÐÒÉ
ÌÅËÓÉËÏÇÒÁÆÉÞÅÓËÏÍ ÓÒÁ×ÎÅÎÉÉ) ÓÔÒÏËÉ <em> string2</em>.
</dd>
<dt><strong><a name="string first"></a>string</strong> <strong>first</strong>
<em>string1</em> <em>string2</em></dt>
<dd>éÝÅÔ × ÓÔÒÏËÅ <em>string2</em> ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÓÉÍ×ÏÌÏ×, ×
ÔÏÞÎÏÓÔÉ ÓÏ×ÐÁÄÁÀÝÕÀ ÓÏ <em>string1</em>. åÓÌÉ ÔÁËÁÑ
ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÅÓÔØ, ×ÏÚ×ÒÁÝÁÅÔ ÉÎÄÅËÓ ÐÅÒ×ÏÊ ÂÕË×Ù ×
ÐÅÒ×ÏÊ ÎÁÊÄÅÎÎÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÉ. ÷ ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ
×ÏÚ×ÒÁÝÁÅÔ -1.
</dd>
<dt><strong><a name="string index"></a>string</strong> <strong>index</strong> <em>string</em>
<em>charIndex</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ <em>charIndex</em>-ÎÙÊ ÓÉÍ×ÏÌ × ÓÔÒÏËÅ <em>
string</em>. úÎÁÞÅÎÉÅ <em>charIndex</em>, ÒÁ×ÎÏÅ 0,
ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÐÅÒ×ÏÍÕ ÓÉÍ×ÏÌÕ × ÓÔÒÏËÅ. åÓÌÉ ÚÎÁÞÅÎÉÅ <em>
charIndex</em> ÍÅÎØÛÅ 0 ÉÌÉ ÎÅ ÍÅÎØÛÅ ÄÌÉÎÙ ÓÔÒÏËÉ
- ×ÏÚ×ÒÁÝÁÅÔ ÐÕÓÔÕÀ ÓÔÒÏËÕ.
</dd>
<dt><strong><a name="string last"></a>string</strong> <strong>last</strong>
<em>string1</em> <em>string2</em></dt>
<dd>éÝÅÔ × ÓÔÒÏËÅ <em>string2</em> ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÓÉÍ×ÏÌÏ×, ×
ÔÏÞÎÏÓÔÉ ÓÏ×ÐÁÄÁÀÝÕÀ ÓÏ <em>string1</em>. åÓÌÉ ÔÁËÁÑ
ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÅÓÔØ, ×ÏÚ×ÒÁÝÁÅÔ ÉÎÄÅËÓ ÐÅÒ×ÏÊ ÂÕË×Ù ×
ÐÏÓÌÅÄÎÅÊ ÎÁÊÄÅÎÎÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÉ. ÷ ÐÒÏÔÉ×ÎÏÍ ÓÌÕÞÁÅ
×ÏÚ×ÒÁÝÁÅÔ -1.
</dd>
<dt><strong><a name="string length"></a>string</strong> <strong>length</strong>
<em>string</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÄÅÓÑÔÉÞÎÕÀ ÓÔÒÏËÕ, ÓÏÄÅÒÖÁÝÕÀ ÞÉÓÌÏ ÓÉÍ×ÏÌÏ× ×
ÓÔÒÏËÅ.
</dd>
<dt><strong><a name="string match"></a>string</strong> <strong>match</strong>
<em>pattern</em> <em>string</em></dt>
<dd><p>ðÒÏ×ÅÒÑÅÔ, ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÌÉ ÓÔÒÏËÁ ÏÂÒÁÚÃÕ. ÷ÏÚ×ÒÁÝÁÅÔ
1, ÅÓÌÉ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ, É 0 - × ÐÒÏÔÉ×ÎÏÍ
ÓÌÕÞÁÅ. óÏÏÔ×ÅÔÓÔ×ÉÅ ÐÒÏ×ÅÒÑÅÔÓÑ ÐÒÉÍÅÒÎÏ ÔÁË ÖÅ, ËÁË ×
C-shell. óÔÒÏËÁ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÛÁÂÌÏÎÕ, ÅÓÌÉ ÏÎÉ ÓÏ×ÐÁÄÁÀÔ
ÐÏÓÉÍ×ÏÌØÎÏ, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ÐÅÒÅÞÉÓÌÅÎÎÙÈ ÎÉÖÅ ÓÐÅÃÉÁÌØÎÙÈ
ÓÌÕÞÁÅ×:</p>
<table>
<tbody>
<tr>
<td>*</td>
<td>õÄÏ×ÌÅÔ×ÏÒÑÅÔ ÌÀÂÏÊ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÉ ÉÚ ÎÕÌÑ
ÉÌÉ ÂÏÌØÛÅ ÓÉÍ×ÏÌÏ×;</td>
</tr>
<tr>
<td>?</td>
<td>õÄÏ×ÌÅÔ×ÏÒÑÅÔ ÌÀÂÏÍÕ ÓÉÍ×ÏÌÕ;</td>
</tr>
<tr>
<td><strong>[<em>chars</em>]</strong></td>
<td> õÄÏ×ÌÅÔ×ÏÒÑÅÔ ÌÀÂÏÍÕ ÓÉÍ×ÏÌÕ ÉÚ <em>chars</em>. åÓÌÉ
<em>chars</em> ×ËÌÀÞÁÅÔ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÓÉÍ×ÏÌÏ× ÔÉÐÁ
<em>a-b</em>, ÔÏ ÕÄÏ×ÌÅÔ×ÏÒÑÅÔ ×ÓÅÍ ÓÉÍ×ÏÌÁÍ ÏÔ <em>a</em>
ÄÏ <em>b</em> (×ËÌÀÞÉÔÅÌØÎÏ).</td>
</tr>
<tr>
<td>\x</td>
<td>õÄÏ×ÌÅÔ×ÏÒÑÅÔ ÓÉÍ×ÏÌÕ x. ïÂÅÓÐÅÞÉ×ÁÅÔ ×ÏÚÍÏÖÎÏÓÔØ
ÉÚÂÅÖÁÔØ × ÛÁÂÌÏÎÁÈ ÓÐÅÃÉÁÌØÎÏÇÏ ÓÍÙÓÌÁ ÓÉÍ×ÏÌÏ× *, ?,
[, ], \.</td>
</tr>
</tbody>
</table>
</dd>
<dt><strong><a name="string range"></a>string</strong> <strong>range</strong> <em>string</em>
<em>first</em> <em>last</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÐÏÄÓÔÒÏËÕ ÓÔÒÏËÉ <em>string</em>, ÎÁÞÉÎÁÑ Ó ÓÉÍ×ÏÌÁ
Ó ÉÎÄÅËÓÏÍ <em>first</em> É ËÏÎÞÁÑ ÓÉÍ×ÏÌÏÍ Ó ÉÎÄÅËÓÏÍ
<em>last</em>. éÎÄÅËÓ <strong>0</strong> ÕËÁÚÙ×ÁÅÔ ÎÁ ÐÅÒ×ÙÊ ÓÉÍ×ÏÌ
ÓÔÒÏËÉ. éÎÄÅËÓ <strong>end</strong> (ÉÌÉ ÌÀÂÏÅ ÅÇÏ ÓÏËÒÁÝÅÎÉÅ) ÕËÁÚÙ×ÁÅÔ
ÎÁ ÐÏÓÌÅÄÎÉÊ ÓÉÍ×ÏÌ ÓÔÒÏËÉ. åÓÌÉ ÚÎÁÞÅÎÉÅ <em>first</em> ÍÅÎØÛÅ
<strong>0</strong>, ÉÓÐÏÌØÚÕÅÔÓÑ ÚÎÁÞÅÎÉÅ <strong>0</strong>. åÓÌÉ <em>last</em>
ÂÏÌØÛÅ ÚÎÁÞÅÎÉÑ ÉÎÄÅËÓÁ ÐÏÓÌÅÄÎÅÇÏ ÓÉÍ×ÏÌÁ × ÓÔÒÏËÅ,
ÉÓÐÏÌØÚÕÅÔÓÑ ÚÎÁÞÅÎÉÅ <strong>end</strong>. åÓÌÉ <em>first</em> ÂÏÌØÛÅ,
ÞÅÍ <em>last</em>, ËÏÍÁÎÄÁ ×ÏÚ×ÒÁÝÁÅÔ ÐÕÓÔÕÀ ÓÔÒÏËÕ.
</dd>
<dt><strong><a name="string tolower"></a>string</strong> <strong>tolower</strong>
<em>string</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÓÔÒÏËÕ, ÔÏÖÄÅÓÔ×ÅÎÎÕÀ <em>string</em>, ÚÁ
ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ×ÓÅ ÓÉÍ×ÏÌÙ ×ÅÒÈÎÅÇÏ ÒÅÇÉÓÔÒÁ × ÎÅÊ
ÐÅÒÅ×ÅÄÅÎÙ × ÎÉÖÎÉÊ ÒÅÇÉÓÔÒ.
</dd>
<dt><strong><a name="string toupper"></a>string</strong> <strong>toupper</strong>
<em>string</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÓÔÒÏËÕ, ÔÏÖÄÅÓÔ×ÅÎÎÕÀ <em>string</em>, ÚÁ
ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ×ÓÅ ÓÉÍ×ÏÌÙ ÎÉÖÎÅÇÏ ÒÅÇÉÓÔÒÁ × ÎÅÊ
ÐÅÒÅ×ÅÄÅÎÙ × ×ÅÒÈÎÉÊ ÒÅÇÉÓÔÒ.
</dd>
<dt><strong>string</strong> <strong>trim</strong> <em>string</em> ?<em>chars</em>?</dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÓÔÒÏËÕ, ÔÏÖÄÅÓÔ×ÅÎÎÕÀ <em>string</em>, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ
ÔÏÇÏ, ÞÔÏ ÉÚ ÎÅÅ ÕÄÁÌÅÎÙ ×ÓÅ ÎÁÞÁÌØÎÙÅ É ËÏÎÅÞÎÙÅ ÓÉÍ×ÏÌÙ,
×ÈÏÄÑÝÉÅ × <em>chars</em>. åÓÌÉ ÁÒÇÕÍÅÎÔ <em>chars</em> ÎÅ ÕËÁÚÁÎ,
ÕÄÁÌÑÀÔÓÑ ÐÒÏÂÅÌØÎÙÅ ÓÉÍ×ÏÌÙ (ÐÒÏÂÅÌÙ, ÔÁÂÕÌÑÃÉÑ, ÓÉÍ×ÏÌÙ
ÎÏ×ÏÊ ÓÔÒÏËÉ).
</dd>
<dt><strong><a name="string trimleft"></a>string</strong> <strong>trimleft</strong>
<em>string</em> ?<em>chars</em>? </dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÓÔÒÏËÕ, ÔÏÖÄÅÓÔ×ÅÎÎÕÀ <em>string</em>, ÚÁ
ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÉÚ ÎÅÅ ÕÄÁÌÅÎÙ ×ÓÅ ÎÁÞÁÌØÎÙÅ ÓÉÍ×ÏÌÙ,
×ÈÏÄÑÝÉÅ × <em>chars</em>. åÓÌÉ ÁÒÇÕÍÅÎÔ <em>chars</em> ÎÅ ÕËÁÚÁÎ,
ÕÄÁÌÑÀÔÓÑ ÐÒÏÂÅÌØÎÙÅ ÓÉÍ×ÏÌÙ (ÐÒÏÂÅÌÙ, ÔÁÂÕÌÑÃÉÑ, ÓÉÍ×ÏÌÙ
ÎÏ×ÏÊ ÓÔÒÏËÉ).
</dd>
<dt><strong><a name="string trimleft"></a>string</strong> <strong>trimright</strong>
<em>string</em> ?<em>chars</em>? </dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÓÔÒÏËÕ, ÔÏÖÄÅÓÔ×ÅÎÎÕÀ <em>string</em>, ÚÁ
ÉÓËÌÀÞÅÎÉÅÍ ÔÏÇÏ, ÞÔÏ ÉÚ ÎÅÅ ÕÄÁÌÅÎÙ ×ÓÅ ËÏÎÅÞÎÙÅ ÓÉÍ×ÏÌÙ,
×ÈÏÄÑÝÉÅ × <em>chars</em>. åÓÌÉ ÁÒÇÕÍÅÎÔ <em>chars</em> ÎÅ
ÕËÁÚÁÎ, ÕÄÁÌÑÀÔÓÑ ÐÒÏÂÅÌØÎÙÅ ÓÉÍ×ÏÌÙ (ÐÒÏÂÅÌÙ, ÔÁÂÕÌÑÃÉÑ,
ÓÉÍ×ÏÌÙ ÎÏ×ÏÊ ÓÔÒÏËÉ).
</dd>
<dt><strong><a name="string wordend"></a>string</strong> <strong>wordend</strong>
<em>string</em> <em>index</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÉÎÄÅËÓ ÓÉÍ×ÏÌÁ, ÉÄÕÝÅÇÏ ÓÒÁÚÕ ÐÏÓÌÅ ÐÏÓÌÅÄÎÅÇÏ
ÓÉÍ×ÏÌÁ × ÓÌÏ×Å, ÓÏÄÅÒÖÁÝÅÍ <em>index</em>-ÎÙÊ ÓÉÍ×ÏÌ ÓÔÒÏËÉ
<em>string</em>. óÌÏ×ÏÍ ÓÞÉÔÁÅÔÓÑ ÌÀÂÁÑ ÎÅÐÒÅÒÙ×ÎÁÑ
ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÉÚ ÂÕË×, ÃÉÆÒ É ÓÉÍ×ÏÌÁ ÐÏÄÞÅÒËÉ×ÁÎÉÑ,
ÉÌÉ ÌÀÂÏÊ ÄÒÕÇÏÊ ÏÄÉÎÏÞÎÙÊ ÓÉÍ×ÏÌ.
</dd>
<dt><strong><a name="string wordstart"></a>string</strong> <strong>wordstart</strong>
<em>string</em> <em>index</em></dt>
<dd>÷ÏÚ×ÒÁÝÁÅÔ ÉÎÄÅËÓ ÐÅÒ×ÏÇÏ ÓÉÍ×ÏÌÁ × ÓÌÏ×Å, ÓÏÄÅÒÖÁÝÅÍ
<em>index</em>-ÎÙÊ ÓÉÍ×ÏÌ ÓÔÒÏËÉ <em>string</em>. óÌÏ×ÏÍ ÓÞÉÔÁÅÔÓÑ
ÌÀÂÁÑ ÎÅÐÒÅÒÙ×ÎÁÑ ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔØ ÉÚ ÂÕË×, ÃÉÆÒ É ÓÉÍ×ÏÌÁ
ÐÏÄÞÅÒËÉ×ÁÎÉÑ, ÉÌÉ ÌÀÂÏÊ ÄÒÕÇÏÊ ÏÄÉÎÏÞÎÙÊ ÓÉÍ×ÏÌ.
</dd>
</dl>
</body>
</html>