{"id":5962,"date":"2022-12-20T18:57:47","date_gmt":"2022-12-20T21:57:47","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/string-mann\/"},"modified":"2022-12-20T18:57:47","modified_gmt":"2022-12-20T21:57:47","slug":"string-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/string-mann\/","title":{"rendered":"string (mann)"},"content":{"rendered":"<h1 align=\"center\">string<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#STRING INDICES\">STRING INDICES<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">string \u2212 Manipulate strings<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>string<\/b> <i>option arg<\/i> ?<i>arg &#8230;?<\/i> ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Performs one of several string operations, depending on <i>option<\/i>. The legal <i>option<\/i>s (which may be abbreviated) are: <b><br \/> string cat<\/b> ?<i>string1<\/i>? ?<i>string2&#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Concatenate the given <i>string<\/i>s just like placing them directly <big>\u2502<\/big> next to each other and return the resulting compound string. If <big>\u2502<\/big> no <i>string<\/i>s are present, the result is an empty string. <big>\u2502<\/big><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">This primitive is occasionally handier than juxtaposition of <big>\u2502<\/big> strings when mixed quoting is wanted, or when the aim is to <big>\u2502<\/big> return the result of a concatenation without resorting to <b>return<\/b> <big>\u2502<\/big> <b>\u2212level 0<\/b>, and is more efficient than building a list of <big>\u2502<\/big> arguments and using <b>join<\/b> with an empty join string. <big>\u2502<\/big><\/p>\n<p style=\"margin-left:11%;\"><b>string compare<\/b> ?<b>\u2212nocase<\/b>? ?<b>\u2212length<\/b> <i>length<\/i>? <i>string1 string2<\/i><\/p>\n<p style=\"margin-left:22%;\">Perform a character-by-character comparison of strings <i>string1<\/i> and <i>string2<\/i>. Returns \u22121, 0, or 1, depending on whether <i>string1<\/i> is lexicographically less than, equal to, or greater than <i>string2<\/i>. If <b>\u2212length<\/b> is specified, then only the first <i>length<\/i> characters are used in the comparison. If <b>\u2212length<\/b> is negative, it is ignored. If <b>\u2212nocase<\/b> is specified, then the strings are compared in a case-insensitive manner.<\/p>\n<p style=\"margin-left:11%;\"><b>string equal<\/b> ?<b>\u2212nocase<\/b>? ?<b>\u2212length<\/b> <i>length<\/i>? <i>string1 string2<\/i><\/p>\n<p style=\"margin-left:22%;\">Perform a character-by-character comparison of strings <i>string1<\/i> and <i>string2<\/i>. Returns 1 if <i>string1<\/i> and <i>string2<\/i> are identical, or 0 when not. If <b>\u2212length<\/b> is specified, then only the first <i>length<\/i> characters are used in the comparison. If <b>\u2212length<\/b> is negative, it is ignored. If <b>\u2212nocase<\/b> is specified, then the strings are compared in a case-insensitive manner.<\/p>\n<p style=\"margin-left:11%;\"><b>string first<\/b> <i>needleString haystackString<\/i> ?<i>startIndex<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Search <i>haystackString<\/i> for a sequence of characters that exactly match the characters in <i>needleString<\/i>. If found, return the index of the first character in the first such match within <i>haystackString<\/i>. If not found, return \u22121. If <i>startIndex<\/i> is specified (in any of the forms described in <b>STRING INDICES<\/b>), then the search is constrained to start with the character in <i>haystackString<\/i> specified by the index. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string first a 0a23456789abcdef 5<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">will return <b>10<\/b>, but<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string first a 0123456789abcdef 11<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">will return <b>\u22121<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string index<\/b> <i>string charIndex<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the <i>charIndex<\/i>\u2019th character of the <i>string<\/i> argument. A <i>charIndex<\/i> of 0 corresponds to the first character of the string. <i>charIndex<\/i> may be specified as described in the <b>STRING INDICES<\/b> section.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">If <i>charIndex<\/i> is less than 0 or greater than or equal to the length of the string then this command returns an empty string.<\/p>\n<p style=\"margin-left:11%;\"><b>string is<\/b> <i>class<\/i> ?<b>\u2212strict<\/b>? ?<b>\u2212failindex<\/b> <i>varname<\/i>? <i>string<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns 1 if <i>string<\/i> is a valid member of the specified character class, otherwise returns 0. If <b>\u2212strict<\/b> is specified, then an empty string returns 0, otherwise an empty string will return 1 on any class. If <b>\u2212failindex<\/b> is specified, then if the function returns 0, the index in the string where the class was no longer valid will be stored in the variable named <i>varname<\/i>. The <i>varname<\/i> will not be set if <b>string is<\/b> returns 1. The following character classes are recognized (the class name can be abbreviated):<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>alnum<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode alphabet or digit character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>alpha<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode alphabet character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>ascii<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any character with a value less than u0080 (those that are in the 7\u2212bit ascii range).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>boolean<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the forms allowed to <b>Tcl_GetBoolean<\/b>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>control<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode control character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>digit<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode digit character. Note that this includes characters outside of the [0\u22129] range.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>double<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the forms allowed to <b>Tcl_GetDoubleFromObj<\/b>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>entier<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the valid string formats for an integer value <big>\u2502<\/big> of arbitrary size in Tcl, with optional surrounding <big>\u2502<\/big> whitespace. The formats accepted are exactly those <big>\u2502<\/big> accepted by the C routine <b>Tcl_GetBignumFromObj<\/b>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>false<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the forms allowed to <b>Tcl_GetBoolean<\/b> where the value is false.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>graph<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode printing character, except space.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>integer<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the valid string formats for a 32-bit integer value in Tcl, with optional surrounding whitespace. In case of overflow in the value, 0 is returned and the <i>varname<\/i> will contain \u22121.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>list<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any proper list structure, with optional surrounding whitespace. In case of improper list structure, 0 is returned and the <i>varname<\/i> will contain the index of the \u201celement\u201d where the list parsing fails, or \u22121 if this cannot be determined.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>lower<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode lower case alphabet character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>print<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode printing character, including space.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>punct<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode punctuation character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>space<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode whitespace character, mongolian vowel separator (U+180e), zero width space (U+200b), word joiner (U+2060) or zero width no-break space (U+feff) (=BOM).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>true<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the forms allowed to <b>Tcl_GetBoolean<\/b> where the value is true.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>upper<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any upper case alphabet character in the Unicode character set.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>wideinteger<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any of the valid forms for a wide integer in Tcl, with optional surrounding whitespace. In case of overflow in the value, 0 is returned and the <i>varname<\/i> will contain \u22121.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>wordchar<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any Unicode word character. That is any alphanumeric character, and any Unicode connector punctuation characters (e.g. underscore).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"16%\">\n<p><b>xdigit<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"60%\">\n<p>Any hexadecimal digit character ([0\u22129A\u2212Fa\u2212f]).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%; margin-top: 1em\">In the case of <b>boolean<\/b>, <b>true<\/b> and <b>false<\/b>, if the function will return 0, then the <i>varname<\/i> will always be set to 0, due to the varied nature of a valid boolean value.<\/p>\n<p style=\"margin-left:11%;\"><b>string last<\/b> <i>needleString haystackString<\/i> ?<i>lastIndex<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Search <i>haystackString<\/i> for a sequence of characters that exactly match the characters in <i>needleString<\/i>. If found, return the index of the first character in the last such match within <i>haystackString<\/i>. If there is no match, then return \u22121. If <i>lastIndex<\/i> is specified (in any of the forms described in <b>STRING INDICES<\/b>), then only the characters in <i>haystackString<\/i> at or before the specified <i>lastIndex<\/i> will be considered by the search. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string last a 0a23456789abcdef 15<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">will return <b>10<\/b>, but<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string last a 0a23456789abcdef 9<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">will return <b>1<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string length<\/b> <i>string<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the number of characters in <i>string<\/i>. Note that this is not necessarily the same as the number of bytes used to store the string. If the value is a byte array value (such as those returned from reading a binary encoded channel), then this will return the actual byte length of the value.<\/p>\n<p style=\"margin-left:11%;\"><b>string map<\/b> ?<b>\u2212nocase<\/b>? <i>mapping string<\/i><\/p>\n<p style=\"margin-left:22%;\">Replaces substrings in <i>string<\/i> based on the key-value pairs in <i>mapping<\/i>. <i>mapping<\/i> is a list of <i>key value key value &#8230;<\/i> as in the form returned by <b>array get<\/b>. Each instance of a key in the string will be replaced with its corresponding value. If <b>\u2212nocase<\/b> is specified, then matching is done without regard to case differences. Both <i>key<\/i> and <i>value<\/i> may be multiple characters. Replacement is done in an ordered manner, so the key appearing first in the list will be checked first, and so on. <i>string<\/i> is only iterated over once, so earlier key replacements will have no affect for later key matches. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string map {abc 1 ab 2 a 3 1 0} 1abcaababcabababc<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">will return the string <b>01321221<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Note that if an earlier <i>key<\/i> is a prefix of a later one, it will completely mask the later one. So if the previous example is reordered like this,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string map {1 0 ab 2 a 3 abc 1} 1abcaababcabababc<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">it will return the string <b>02c322c222c<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string match<\/b> ?<b>\u2212nocase<\/b>? <i>pattern string<\/i><\/p>\n<p style=\"margin-left:22%;\">See if <i>pattern<\/i> matches <i>string<\/i>; return 1 if it does, 0 if it does not. If <b>\u2212nocase<\/b> is specified, then the pattern attempts to match against the string in a case insensitive manner. For the two strings to match, their contents must be identical except that the following special sequences may appear in <i>pattern<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"10%\">\n<p><b>*<\/b><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"63%\">\n<p>Matches any sequence of characters in <i>string<\/i>, including a null string.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"10%\">\n<p><b>?<\/b><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"63%\">\n<p>Matches any single character in <i>string<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"10%\">\n<p><b>[<\/b><i>chars<\/i><b>]<\/b><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"63%\">\n<p>Matches any character in the set given by <i>chars<\/i>. If a sequence of the form <i>x<\/i><b>\u2212<\/b><i>y<\/i> appears in <i>chars<\/i>, then any character between <i>x<\/i> and <i>y<\/i>, inclusive, will match. When used with <b>\u2212nocase<\/b>, the end points of the range are converted to lower case first. Whereas {[A\u2212z]} matches \u201c_\u201d when matching case-sensitively (since \u201c_\u201d falls between the \u201cZ\u201d and \u201ca\u201d), with <b>\u2212nocase<\/b> this is considered like {[A\u2212Za\u2212z]} (and probably what was meant in the first place).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"10%\">\n<p><b><\/b><i>x<\/i><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"63%\">\n<p>Matches the single character <i>x<\/i>. This provides a way of avoiding the special interpretation of the characters <b>*?[]<\/b> in <i>pattern<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><b>string range<\/b> <i>string first last<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a range of consecutive characters from <i>string<\/i>, starting with the character whose index is <i>first<\/i> and ending with the character whose index is <i>last<\/i>. An index of 0 refers to the first character of the string. <i>first<\/i> and <i>last<\/i> may be specified as for the <b>index<\/b> method. If <i>first<\/i> is less than zero then it is treated as if it were zero, and if <i>last<\/i> is greater than or equal to the length of the string then it is treated as if it were <b>end<\/b>. If <i>first<\/i> is greater than <i>last<\/i> then an empty string is returned.<\/p>\n<p style=\"margin-left:11%;\"><b>string repeat<\/b> <i>string count<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <i>string<\/i> repeated <i>count<\/i> number of times.<\/p>\n<p style=\"margin-left:11%;\"><b>string replace<\/b> <i>string first last<\/i> ?<i>newstring<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Removes a range of consecutive characters from <i>string<\/i>, starting with the character whose index is <i>first<\/i> and ending with the character whose index is <i>last<\/i>. An index of 0 refers to the first character of the string. <i>First<\/i> and <i>last<\/i> may be specified as for the <b>index<\/b> method. If <i>newstring<\/i> is specified, then it is placed in the removed character range. If <i>first<\/i> is less than zero then it is treated as if it were zero, and if <i>last<\/i> is greater than or equal to the length of the string then it is treated as if it were <b>end<\/b>. If <i>first<\/i> is greater than <i>last<\/i> or the length of the initial string, or <i>last<\/i> is less than 0, then the initial string is returned untouched.<\/p>\n<p style=\"margin-left:11%;\"><b>string reverse<\/b> <i>string<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a string that is the same length as <i>string<\/i> but with its characters in the reverse order.<\/p>\n<p style=\"margin-left:11%;\"><b>string tolower<\/b> <i>string<\/i> ?<i>first<\/i>? ?<i>last<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that all upper (or title) case letters have been converted to lower case. If <i>first<\/i> is specified, it refers to the first char index in the string to start modifying. If <i>last<\/i> is specified, it refers to the char index in the string to stop at (inclusive). <i>first<\/i> and <i>last<\/i> may be specified using the forms described in <b>STRING INDICES<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string totitle<\/b> <i>string<\/i> ?<i>first<\/i>? ?<i>last<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that the first character in <i>string<\/i> is converted to its Unicode title case variant (or upper case if there is no title case variant) and the rest of the string is converted to lower case. If <i>first<\/i> is specified, it refers to the first char index in the string to start modifying. If <i>last<\/i> is specified, it refers to the char index in the string to stop at (inclusive). <i>first<\/i> and <i>last<\/i> may be specified using the forms described in <b>STRING INDICES<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string toupper<\/b> <i>string<\/i> ?<i>first<\/i>? ?<i>last<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that all lower (or title) case letters have been converted to upper case. If <i>first<\/i> is specified, it refers to the first char index in the string to start modifying. If <i>last<\/i> is specified, it refers to the char index in the string to stop at (inclusive). <i>first<\/i> and <i>last<\/i> may be specified using the forms described in <b>STRING INDICES<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>string trim<\/b> <i>string<\/i> ?<i>chars<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that any leading or trailing characters present in the string given by <i>chars<\/i> are removed. If <i>chars<\/i> is not specified then white space is removed (any character for which <b>string is space<\/b> returns 1, and &#8220;\u0000&#8221;).<\/p>\n<p style=\"margin-left:11%;\"><b>string trimleft<\/b> <i>string<\/i> ?<i>chars<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that any leading characters present in the string given by <i>chars<\/i> are removed. If <i>chars<\/i> is not specified then white space is removed (any character for which <b>string is space<\/b> returns 1, and &#8220;\u0000&#8221;).<\/p>\n<p style=\"margin-left:11%;\"><b>string trimright<\/b> <i>string<\/i> ?<i>chars<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a value equal to <i>string<\/i> except that any trailing characters present in the string given by <i>chars<\/i> are removed. If <i>chars<\/i> is not specified then white space is removed (any character for which <b>string is space<\/b> returns 1, and &#8220;\u0000&#8221;).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>OBSOLETE SUBCOMMANDS<\/b> <br \/> These subcommands are currently supported, but are likely to go away in a future release as their functionality is either virtually never used or highly misleading. <b><br \/> string bytelength<\/b> <i>string<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the number of bytes used to represent <i>string<\/i> in memory when encoded as Tcl\u2019s internal modified UTF\u22128; Tcl may use other encodings for <i>string<\/i> as well, and does not guarantee to only use a single encoding for a particular <i>string<\/i>. Because UTF\u22128 uses a variable number of bytes to represent Unicode characters, the byte length will not be the same as the character length in general. The cases where a script cares about the byte length are rare.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">In almost all cases, you should use the <b>string length<\/b> operation (including determining the length of a Tcl byte array value). Refer to the <b>Tcl_NumUtfChars<\/b> manual entry for more details on the UTF\u22128 representation.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Formally, the <b>string bytelength<\/b> operation returns the content of the <i>length<\/i> field of the <b>Tcl_Obj<\/b> structure, after calling <b>Tcl_GetString<\/b> to ensure that the <i>bytes<\/i> field is populated. This is highly unlikely to be useful to Tcl scripts, as Tcl\u2019s internal encoding is not strict UTF\u22128, but rather a modified CESU\u22128 with a denormalized NUL (identical to that used in a number of places by Java\u2019s serialization mechanism) to enable basic processing with non-Unicode-aware C functions. As this representation should only ever be used by Tcl\u2019s implementation, the number of bytes used to store the representation is of very low value (except to C extension code, which has direct access for the purpose of memory management, etc.)<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>Compatibility note:<\/i> it is likely that this subcommand will be withdrawn in a future version of Tcl. It is better to use the <b>encoding convertto<\/b> command to convert a string to a known encoding and then apply <b>string length<\/b> to that.<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>string length<\/b> [encoding convertto utf-8 $theString]<\/p>\n<p style=\"margin-left:11%;\"><b>string wordend<\/b> <i>string charIndex<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the index of the character just after the last one in the word containing character <i>charIndex<\/i> of <i>string<\/i>. <i>charIndex<\/i> may be specified using the forms in <b>STRING INDICES<\/b>. A word is considered to be any contiguous range of alphanumeric (Unicode letters or decimal digits) or underscore (Unicode connector punctuation) characters, or any single character other than these.<\/p>\n<p style=\"margin-left:11%;\"><b>string wordstart<\/b> <i>string charIndex<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the index of the first character in the word containing character <i>charIndex<\/i> of <i>string<\/i>. <i>charIndex<\/i> may be specified using the forms in <b>STRING INDICES<\/b>. A word is considered to be any contiguous range of alphanumeric (Unicode letters or decimal digits) or underscore (Unicode connector punctuation) characters, or any single character other than these.<\/p>\n<h2>STRING INDICES <a name=\"STRING INDICES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">When referring to indices into a string (e.g., for <b>string index<\/b> or <b>string range<\/b>) the following formats are supported:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>integer<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>For any index value that passes <b>string is integer \u2212strict<\/b>, the char specified at this integral index (e.g., <b>2<\/b> would refer to the \u201cc\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><b>end<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>The last char of the string (e.g., <b>end<\/b> would refer to the \u201cd\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><b>end\u2212<\/b><i>N<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>The last char of the string minus the specified integer offset <i>N<\/i> (e.g., \u201c<b>end\u22121<\/b>\u201d would refer to the \u201cc\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><b>end+<\/b><i>N<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>The last char of the string plus the specified integer offset <i>N<\/i> (e.g., \u201c<b>end+\u22121<\/b>\u201d would refer to the \u201cc\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>M<\/i><b>+<\/b><i>N<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>The char specified at the integral index that is the sum of integer values <i>M<\/i> and <i>N<\/i> (e.g., \u201c<b>1+1<\/b>\u201d would refer to the \u201cc\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>M<\/i><b>\u2212<\/b><i>N<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>The char specified at the integral index that is the difference of integer values <i>M<\/i> and <i>N<\/i> (e.g., \u201c<b>2\u22121<\/b>\u201d would refer to the \u201cb\u201d in \u201cabcd\u201d).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">In the specifications above, the integer value <i>M<\/i> contains no trailing whitespace and the integer value <i>N<\/i> contains no leading whitespace.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Test if the string in the variable <i>string<\/i> is a proper non-empty prefix of the string <b>foobar<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set length [<b>string length<\/b> $string] <br \/> if {$length == 0} { <br \/> set isPrefix 0 <br \/> } else { <br \/> set isPrefix [<b>string equal<\/b> \u2212length $length $string &#8220;foobar&#8221;] <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">expr(n), list(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">case conversion, compare, index, match, pattern, string, word, equal, ctype, character, reverse<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  string \u2212 Manipulate strings <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2635,2656],"class_list":["post-5962","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-string"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5962"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5962\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}