substr("abc", 2, 1) /* returns "b" */ substr("abc", 2) /* returns "bc" */ substr("abc", 2, 6) /* returns "bc " */ substr("abc", 2, 6, "*") /* returns "bc****" */ Uppercase // Example in C# "Wiki means fast?".ToUpper(); // "WIKI MEANS FAST?" # Example in Perl 5 uc("Wiki means fast?"); # "WIKI MEANS FAST?" # Example in Raku uc("Wiki means fast?"); # "WIKI MEANS FAST?" "Wiki means fast?".uc; # "WIKI MEANS FAST?" /* Example in Rexx */ translate("Wiki means fast?") /* "WIKI MEANS FAST?" */ /* Example #2 */ A='This is an example.' UPPER A /* "THIS IS AN EXAMPLE." */ /* Example #3 */ A='upper using Translate Function.' Translate UPPER VAR A Z /* Z="UPPER USING TRANSLATE FUNCTION." */ ; Example in Scheme (use-modules (srfi srfi-13)) (string-upcase "Wiki means fast?") ; "WIKI MEANS FAST?" ' Example in Visual Basic UCase("Wiki means fast?") ' "WIKI MEANS FAST?" trim trim or strip is used to remove whitespace from the beginning, end, or both beginning and end, of a string. Other languages In languages without a built-in trim function, it is usually simple to create a custom function which accomplishes the same task. APL APL can use regular expressions directly: Trim←'^ +| +$'⎕R'' Alternatively, a functional approach combining Boolean masks that filter away leading and trailing spaces: Trim←{⍵/⍨(∨\∧∘⌽∨\∘⌽)' '≠⍵} Or reverse and remove leading spaces, twice: Trim←{(∨\' '≠⍵)/⍵}∘⌽⍣2 AWK In AWK, one can use regular expressions to trim: ltrim(v) = gsub(/^[ \t]+/, "", v) rtrim(v) = gsub(/[ \t]+$/, "", v) trim(v) = ltrim(v); rtrim(v) or: function ltrim(s) { sub(/^[ \t]+/, "", s); return s } function rtrim(s) { sub(/[ \t]+$/, "", s); return s } function trim(s) { return rtrim(ltrim(s)); } C/C++ There is no standard trim function in C or C++. Most of the available string libraries for C contain code which implements trimming, or functions that significantly ease an efficient implementation. The function has also often been called EatWhitespace in some non-standard C libraries. In C, programmers often combine a ltrim and rtrim to implement trim: #include <string.h> #include <ctype.h> void rtrim(char *str) { char *s; s = str + strlen(str); while (--s >= str) { if (!isspace(*s)) break; *s = 0; } } void ltrim(char *str) { size_t n; n = 0; while (str[n] != '\0' && isspace((unsigned char) str[n])) { n++; } memmove(str, str + n, strlen(str) - n + 1); } void trim(char *str) { rtrim(str); ltrim(str); }