Examine individual changes
This page allows you to examine the variables generated by the Edit Filter for an individual change.
Variables generated for this change
Variable | Value |
---|---|
Name of the user account (user_name ) | '87.194.117.80' |
Page ID (page_id ) | '3681422' |
Page namespace (page_namespace ) | 0 |
Page title without namespace (page_title ) | 'Comparison of programming languages (string functions)' |
Full page title (page_prefixedtitle ) | 'Comparison of programming languages (string functions)' |
Action (action ) | 'edit' |
Edit summary/reason (summary ) | '/* Compare (integer result, fast/non-human ordering) */ Remove section; see justification on talk page.' |
Whether or not the edit is marked as minor (no longer in use) (minor_edit ) | false |
Old page wikitext, before the edit (old_wikitext ) | '{{redirect|String functions|string functions in formal language theory|String operations}}
<!--
##################################
A NOTE TO CONTRIBUTORS:
Thanks to all who have submitted code samples from various programming languages.
When adding code samples, *please* do not include extraneous characters and symbols
that are not a part of the programming language itself (such as interactive command
prompts). This causes unnecessary confusion for general readers.
The code examples should at least be able to compile without errors when directly cut
and pasted into a source code file.
##################################
-->
{{ProgLangCompare}}
String [[Function (computer science)|functions]] are used in computer [[programming language]]s to manipulate a [[String (computer science)|string]] or query information about a string (some do both).
Most computer programming languages that have a string [[datatype]] will have some string functions although there may be other low level ways within each language to handle strings directly. In object oriented languages, string functions are often implemented as properties and methods of string objects. In functional and list based languages a string is represented as a list (of character codes), therefore all list-manipulation procedures could be considered string functions. However such languages may implement a subset of explicit string-specific functions as well.
The most basic example of a string function is the ''length(string)'' function. This function returns the length of a [[string literal]].
:eg. ''length("hello world")'' would return 11.
Other languages may have string functions with similar or exactly the same syntax or parameters or outcomes. For example in many languages the length function is usually represented as ''[[Len (programming)|len]](string)''. The below list of common functions aims to help limit this confusion.
==Common String Functions (multi language reference)==
Here is a list of common string functions which are found in other languages. Any other equivalent functions used by other languages are also listed. The below list of common functions aims to help programmers find the equivalent function in a language. Note, string [[concatenation]] and [[regular expressions]] are handled in separate pages.
<!-- When giving literal examples please say the language you are using as different languages use different syntax. please list in alpha order. -->
===CharAt===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| charAt(string,integer) returns character.
|-
| Description
| Returns character at index in the string.
|-
| Equivalent
| See [[#substring|substring]] of length 1 character.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! Base index
|-
|''string''[''i'']
|[[ALGOL 68]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|1
|-
|''string''[''i'']
|[[C (programming language)|C]], [[C++]], [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[Python (programming language)|Python]]<sup>1</sup>, [[PHP]], [[Ruby (programming language)|Ruby]]<sup>1</sup>, [[Windows PowerShell]]
|0
|-
|''string''(''i'')
|[[Ada (programming language)|Ada]]
|≥1
|-
|Mid(''string'',i,1)
|[[Visual Basic|VB]]
|1
|-
|''string''.Chars(''i'')
|[[Visual Basic .NET|VB.NET]]
|0
|-
|''string''.charAt(''i'')
|[[Java (programming language)|Java]], [[JavaScript]]
|0
|-
|''string''.[''i'']
|[[OCaml]], [[F Sharp (programming language)|F#]]
|0
|-
|String.sub (''string'', ''i'')
|[[Standard ML]]
|0
|-
|''string'' !! ''i''
|[[Haskell (programming language)|Haskell]]
|0
|-
|(string-ref ''string'' ''i'')
|[[Scheme (programming language)|Scheme]]
|0
|-
|(char ''string'' ''i'')
|[[Common Lisp]]
|0
|-
|substr(''string'', ''i'', 1)
|[[Perl]]<sup>1</sup>
|0
|-
|''string''.at(''i'')
|[[C++]] (<code>[[std::string]]</code> only) (w/ bounds checking)
|0
|-
|string:substr(''string'', ''i'', 1)
|[[Erlang (programming language)|Erlang]]
|1
|-
|[''string'' characterAtIndex:''i'']
|[[Objective-C]] (<code>NSString *</code> only)
|0
|}
# In this language, the index can be negative, which then indicates the number of places before the end of the string.
<pre>
# Example in ALGOL 68 #
"Hello, World"[2]; // 'e'
</pre>
<source lang="csharp">
// Example in C#
"Hello, World"[2]; // 'l'
</source>
<source lang="python">
# Examples in Python
"Hello, World"[2] # 'l'
"Hello, World"[-3] # 'r'
</source>
<source lang="vb">
' Example in Visual Basic
GetChar("Hello, World", 2) ' "e"
</source>
<source lang="vbnet">
' Example in Visual Basic .NET
"Hello, World".Chars(2) ' "l"c
</source>
<!-- endsection -->
===Compare (integer result)===
{|
|- style="background:#fffeed;"
| Definition
| compare(string1,string2) returns integer.
|-
| Description
| Compares two strings to each other. If they are equivalent, a zero is returned. Otherwise, most of these routines will return a positive or negative result corresponding to whether string1 is [[lexicographical order|lexicographically]] greater than, or less than, respectively, than string2. The exceptions are the Scheme and REXX routines which return the index of the first mismatch.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|
IF ''string1''<''string2'' THEN -1 ELSE ABS (''string1''>''string2'') FI
|[[ALGOL 68]]
|-
|cmp(''string1'', ''string2'')
|[[Python (programming language)|Python]]
|-
|[[strcmp]](''string1'', ''string2'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only), [[PHP]]
|-
|std.string.cmp(''string1'', ''string2'')
|[[D (programming language)|D]]
|-
|StrComp(''string1'', ''string2'')
|[[Visual Basic|VB]]
|-
|''string1'' cmp ''string2''
|[[Perl]]
|-
|''string1'' <=> ''string2''
|[[Ruby (programming language)|Ruby]]
|-
|''string1''.compare(''string2'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|compare(''string1'', ''string2'')
|[[REXX (programming language)|REXX]]
|-
|CompareStr(''string1'', ''string2'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|-
|''string1''.compareTo(''string2'')
|[[Java (programming language)|Java]]
|-
|''string1''.CompareTo(''string2'')
|[[Visual Basic .Net|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|(string-compare ''string1'' ''string2'' ''p<'' ''p='' ''p>'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|compare ''string1'' ''string2''
|[[OCaml]]
|-
|String.compare (''string1'', ''string2'')
|[[Standard ML]] (returns LESS, EQUAL, or GREATER)
|-
|compare ''string1'' ''string2''
|[[Haskell (programming language)|Haskell]] (returns LT, EQ, or GT)
|-
|[string]::Compare(''string1'', ''string2'')
|[[Windows PowerShell]]
|-
|[''string1'' compare:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="python">
# Example in Python
cmp("hello", "world") # returns -1
</source>
<source lang="text">
/** Example in REXX */
compare("hello", "world") /* returns index of mismatch: 1 */
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
; returns index of mismatch: 0
(string-compare "hello" "world" values values values)
</source>
<!-- endsection -->
===Compare (integer result, fast/non-human ordering)===
{|
|- style="background:#fffeed;"
| Definition
| compare(string1,string2) returns integer.
|-
| Description
| Compares two strings to each other. If they are equivalent, a zero is returned. Otherwise, most of these routines will return a positive or negative result corresponding to whether string1 is greater than, or less than, respectively, than string2. The reason for the difference between this and [[#Compare (integer result)]] is that no ordering guarantees are given, leaving the implementation to do whatever ordering is fastest, a common implementation is to order by length and then by byte value (which can be significantly faster, but much less useful to humans).
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|if (!(ret = ''string1_len'' - ''string2_len'')) ret = memcmp(''string1'', ''string2'', ''string1_len'');
|[[C (programming language)|C]]
|-
|ustr_cmp_fast(''string1'', ''string2'')
|[http://www.and.org/ustr/ Ustr string library]
|-
|(length(''string1'') <=> length(''string2'') ¦¦ ''string1'' cmp ''string2'')
|[[Perl]]
|-
|cmp(len(''string1''), len(''string2'')) or cmp(''string1'', ''string2'') '''or''' <br /> cmp((len(''string1''), ''string1''), (len(''string2''), ''string2''))
|[[Python (programming language)|Python]]
|-
|(Length(''string1'') <> Length(''string2'')) or CompareStr(''string1'', ''string2'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|-
|compare (length ''string1'') (length ''string2'') `Data.Monoid.mappend` compare ''string1'' ''string2'' '''or'''<br /> compare (length ''string1'', ''string1'') (length ''string2'', ''string2'')
|[[Haskell (programming language)|Haskell]] (returns LT, EQ, or GT)
|-
|compare (String.length ''string1'', ''string1'') (String.length ''string2'', ''string2)
|[[OCaml]]
|-
|[''string1''.length, ''string1''] <=> [''string2''.length, ''string2'']
|[[Ruby (programming language)|Ruby]]
|}
<!-- endsection -->
===Compare (relational operator-based, Boolean result)===
{|
|- style="background:#fffeed;"
| Definition
| string1 op string2 OR (compare string1 string2) returns Boolean.
|-
| Description
| [[lexicographical order|Lexicographically]] compares two strings using a relational operator or function. Boolean result returned.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' op ''string2'', where op can be any of =, <>, <, >, <= and >=
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[OCaml]], [[Standard ML]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]], [[F Sharp (programming language)|F#]]
|-
|''string1'' op ''string2'', where op can be any of =, /=, ≠, <, >, <=, ≤ and ≥; Also: EQ, NE, LT, LE, GE and GT
|[[ALGOL 68]]
|-
|(stringX? ''string1'' ''string2''), where X can be any of =, -ci=, <, -ci<, >, -ci>, <=, -ci<=, >= and -ci>= (operators starting with '-ci' are case-insensitive)
|[[Scheme (programming language)|Scheme]]
|-
|(stringX ''string1'' ''string2''), where X can be any of =, -ci=, <>, -ci<>, <, -ci<, >, -ci>, <=, -ci<=, >= and -ci>= (operators starting with '-ci' are case-insensitive)
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(stringX ''string1'' ''string2''), where X can be any of =, -equal, /=, -not-equal, <, -lessp, >, -greaterp, <=, -not-greaterp, >= and -not-lessp (the verbal operators are case-insensitive)
|[[Common Lisp]]
|-
|''string1'' op ''string2'', where op can be any of =, \=, <, >, <= and >=
|[[REXX (programming language)|REXX]]
|-
|''string1'' op ''string2'', where op can be any of =, /=, <, >, <= and >=
|[[Ada (programming language)|Ada]]
|-
|''string1'' op ''string2'', where op can be any of ==, /=, <, >, =< and >=
|[[Erlang (programming language)|Erlang]]
|-
|''string1'' op ''string2'', where op can be any of ==, /=, <, >, <= and >=
|[[Haskell (programming language)|Haskell]]
|-
|''string1'' op ''string2'', where op can be any of ''eq'', ''ne'', ''lt'', ''gt'', ''le'' and ''ge''
|[[Perl]]
|-
|''string1'' op ''string2'', where op can be any of ==, !=, <, >, <= and >=
|[[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[JavaScript]], [[Python (programming language)|Python]], [[PHP]], [[Ruby (programming language)|Ruby]]
|-
|''string1'' op ''string2'', where op can be any of -eq, -ceq, -ne, -cne, -lt, -clt, -gt, -cgt, -le, -cle, -ge, and -cge (operators starting with 'c' are case-sensitive)
|[[Windows PowerShell]]
|}
<source lang="text">
% Example in Erlang
"hello" > "world". % returns false
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -gt "world" # returns false
</source>
<!-- endsection -->
===Concatenation===
{{main|Concatenation}}
{|
|- style="background:#fffeed;"
| Definition
| concatenate(string1,string2) returns string.
|-
| Description
| Concatenates (joins) two strings to each other, returning the combined string. Note that some languages like C have mutable strings, so really the second string is being appended to the first string and the mutated string is returned.
|}
<!-- table is missing entries for sh -->
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' & ''string2''
|[[Ada (programming language)|Ada]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]]
|-
|strcat(''string1'', ''string2'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only; modifies ''string1'', which must have enough space to store the result)
|-
|''string1'' . ''string2''
|[[Perl]], [[PHP]]
|-
|''string1'' + ''string2''
|[[ALGOL 68]], [[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[Java (programming language)|Java]], [[JavaScript]], [[Windows PowerShell]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[F Sharp (programming language)|F#]], [[Turing (Programming language)|Turing]]
|-
|''string1'' ~ ''string2''
|[[D (programming language)|D]]
|-
|(string-append ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]]
|-
|(concatenate 'string ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' <nowiki>||</nowiki> ''string2''
|[[REXX (programming language)|REXX]], [[Fortran]]
|-
|''string1'' ++ ''string2''
|[[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|''string1'' ^ ''string2''
|[[OCaml]], [[Standard ML]], [[F Sharp (programming language)|F#]]
|-
|[''string1'' stringByAppendingString:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"abc" + "def"; // returns "abcdef"
</source>
<source lang="vb">
' Example in Visual Basic
"abc" & "def" ' returns "abcdef"
</source>
<source lang="d">
// Example in D
"abc" ~ "def"; // returns "abcdef"
</source>
<!-- endsection -->
===Equality===
<!-- startsection -->
Tests if two strings are equal. See also [[#Compare (relational operator-based, Boolean result)|#Compare]] and [[#Compare (integer result)|#Compare]]. Note that doing equality checks via. a generic [[#Compare (integer result)|Compare with integer result]] is not only confusing for the programer but is often a significantly more expensive operation, this is especially true when using "[[String (computer science)#Representations|C-strings]]".
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' == ''string2''
|[[Python (programming language)|Python]], [[C++]](<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[JavaScript]] [[PHP]], [[Ruby (programming language)|Ruby]], [[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|strcmp(''string1'', ''string2'') == 0
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only)
|-
|''string1'' == ''string2''
|[[D (programming language)|D]]
|-
|(string=? ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]]
|-
|(string= ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' = ''string2''
|[[ALGOL 68]], [[Ada (programming language)|Ada]], [[Object Pascal]] (Delphi), [[OCaml]], [[Pascal (programming language)|Pascal]], [[REXX programming language|REXX]], [[Standard ML]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]], [[F Sharp (programming language)|F#]]
|-
|test ''string1'' = ''string2'', or <br />[ ''string1'' = ''string2'' ]
|[[Bourne Shell]]
|-
|''string1'' eq ''string2''
|[[Perl]]
|-
|''string1''.equals(''string2'')
|[[Java (programming language)|Java]]
|-
|''string1'' -eq ''string2'', or <br />[string]::Equals(''string1'', ''string2'')
|[[Windows PowerShell]]
|-
|[''string1'' isEqualToString:''string2''], or <br />[''string1'' isEqual:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"hello" == "world" // returns false
</source>
<source lang="vb">
' Example in Visual Basic
"hello" = "world" ' returns false
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -eq "world" # returns false
</source>
<!-- endsection -->
===Find===
{|
|- style="background:#fffeed;"
| Definition
| find(''string'',''substring'') returns integer
|-
| Description
| Returns the position of the start of the first occurrence of ''substring'' in ''string''. If the ''substring'' is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE.
|-
| Related
| instrrev
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|string in string(substring, pos, ''string[startpos:]'')
|[[ALGOL 68]]
|returns BOOL: TRUE or FALSE, and position in REF INT pos.
|-
|InStr([''startpos'',]''string'',''substring'')
|[[Visual Basic|VB]] (positions start at 1)
|returns 0
|-
|index(''string'',''substring'')
|[[AWK]]
|returns 0
|-
|index(''string'',''substring''[,''startpos''])
|[[Perl]]
|returns -1
|-
|strpos(''string'',''substring''[,''startpos''])
|[[PHP]]
|returns FALSE
|-
|locate(''string'', ''substring'')
|[[Ingres (database)|Ingres]]
|returns string length + 1
|-
|strstr(''string'', ''substring'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only, returns pointer to first character)
|returns NULL
|-
|std.string.find(''string'', ''substring'')
|[[D (programming language)|D]]
|returns -1
|-
|pos(''substring'', ''string'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|returns 0
|-
|pos(''substring'', ''string''[,''startpos''])
|[[REXX (programming language)|REXX]]
|returns 0
|-
|''string''.find(''substring''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|''string''.find(''substring''[,''startpos''[,''endpos'']])
|[[Python (programming language)|Python]]
|returns -1
|-
|''string''.index(''substring''[,''startpos''])
|[[Ruby (programming language)|Ruby]]
|returns nil
|-
|''string''.indexOf(''substring''[,''startpos''])
|[[Java (programming language)|Java]], [[JavaScript]]
|returns -1
|-
|''string''.IndexOf(''substring''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|string:str(''string'', ''substring'')
|[[Erlang (programming language)|Erlang]]
|returns 0
|-
|(string-contains ''string'' ''substring'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|returns #f
|-
|(search ''substring'' ''string'')
|[[Common Lisp]]
|returns NIL
|-
|List.findIndex (List.isPrefixOf ''substring'') (List.tails ''string'')
|[[Haskell (programming language)|Haskell]] (returns Just ''index'')
|returns Nothing
|-
|Str.search_forward (Str.regexp_string ''substring'') ''string'' 0
|[[OCaml]]
|raises Not_found
|-
|Substring.size (#1 (Substring.position ''substring'' (Substring.full ''string'')))
|[[Standard ML]]
|returns string length
|-
|[''string'' rangeOfString:''substring''].___location
|[[Objective-C]] (<code>NSString *</code> only)
|returns NSNotFound
|}
<source lang="lisp">
; Examples in Common Lisp
(search "e" "Hello mate") ; returns 1
(search "z" "word") ; returns NIL
</source>
<source lang="csharp">
// Examples in C#
"Hello mate".IndexOf("e"); // returns 1
"Hello mate".IndexOf("e", 4); // returns 9
"word".IndexOf("z"); // returns -1
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-contains "Hello mate" "e") ; returns 1
(string-contains "word" "z") ; returns #f
</source>
<source lang="vb">
' Examples in Visual Basic
InStr("Hello mate", "e") ' returns 2
InStr(5, "Hello mate", "e") ' returns 10
InStr("word", "z") ' returns 0
</source>
<!-- endsection -->
===Find character===
{|
|- style="background:#fffeed;"
| Definition
| find character(''string'',''char'') returns integer
|-
| Description
| Returns the position of the start of the first occurrence of the character ''char'' in ''string''. If the character is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE. This can be accomplished as a special case of [[#Find]], with a string of one character; but it may be simpler or more efficient in many languages to locate just a single character. Also, in many languages, characters and strings are different types, so it is convenient to have such a function.
|-
| Related
| find
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|char in string(char, pos, ''string[startpos:]'')
|[[ALGOL 68]]
|returns BOOL: TRUE or FALSE, and position in REF INT pos.
|-
|strchr(''string'',''char'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only, returns pointer to character)
|returns NULL
|-
|std.string.find(''string'', ''dchar'')
|[[D (programming language)|D]]
|returns -1
|-
|''string''.find(''char''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|''string''.indexOf(''char''[,''startpos''])
|[[Java (programming language)|Java]]
|returns -1
|-
|''string''.IndexOf(''char''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|(position ''char'' ''string'')
|[[Common Lisp]]
|returns NIL
|-
|List.elemIndex ''char'' ''string''
|[[Haskell (programming language)|Haskell]] (returns Just ''index'')
|returns Nothing
|-
|String.index ''string'' ''char''
|[[OCaml]]
|raises Not_found
|}
<source lang="csharp">
// Examples in C#
"Hello mate".IndexOf('e'); // returns 1
"word".IndexOf('z') // returns -1
</source>
<source lang="lisp">
; Examples in Common Lisp
(position #\e "Hello mate") ; returns 1
(position #\z "word") ; returns NIL
</source>
<!-- endsection -->
===Format===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| format(''formatstring'', ''items'') returns string
|-
| Description
| Returns the formatted string representation of one or more items. See [[printf#sprintf|sprintf]] for more information.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|associate(''file'', ''string''); [[putf]](''file'', ''$formatstring$'', ''items'')
|[[ALGOL 68]]
|-
|Format(''item'', ''formatstring'')
|[[Visual Basic|VB]]
|-
|[[sprintf]](''formatstring'', ''items'')
|[[Perl]], [[PHP]], [[Ruby (programming language)|Ruby]]
|-
|io_lib:format(''formatstring'', ''items'')
|[[Erlang (programming language)|Erlang]]
|-
|[[sprintf]](''outputstring'', ''formatstring'', ''items'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only)
|-
|std.string.format(''formatstring'', ''items'')
|[[D (programming language)|D]]
|-
|[[printf]] -v ''outputstring'' ''formatstring'' ''items''
|[[Unix]]
|-
|''formatstring'' % (''items'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|-
|''formatstring''.format(''items'')
|Python 3.x (format specification is different from printf)
|-
|Printf.sprintf ''formatstring'' ''items''
|[[OCaml]], [[F Sharp (programming language)|F#]]
|-
|Text.Printf.printf ''formatstring'' ''items''
|[[Haskell (programming language)|Haskell]] (GHC)
|-
|String.format(''formatstring'', ''items'')
|[[Java (programming language)|Java]]
|-
|String.Format(''formatstring'', ''items'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|(format ''formatstring'' ''items'')
|[[Scheme (programming language)|Scheme]] (SRFI 28)
|-
|(format nil ''formatstring'' ''items'')
|[[Common Lisp]]
|-
|''formatstring'' -f ''items''
|[[Windows PowerShell]]
|-
|[NSString stringWithFormat:''formatstring'', ''items'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
String.Format("My {0} costs {1:C2}", "pen", 19.99); // returns "My pen costs $19.99"
</source>
<source lang="java5">
// Example in Java
String.format("My %s costs $%2f", "pen", 19.99); // returns "My pen costs $19.99"
</source>
<source lang="perl">
# Example in Perl
sprintf("My %s costs $%2f", "pen", 19.99); # returns "My pen costs $19.99"
</source>
<source lang="Scheme">
; Example in Scheme
(format "My ~a costs $~1,2F" "pen" 19.99) ; returns "My pen costs $19.99"
</source>
<!-- endsection -->
===Inequality===
<!-- startsection -->
Tests if two strings are not equal. See also [[#Equality]].
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' <> ''string2''
|[[Visual Basic|VB]],[[Visual Basic .NET|VB .NET]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[OCaml]], [[Standard ML]], [[F Sharp (programming language)|F#]]
|-
|''string1'' ne ''string2''
|[[Perl]]
|-
|(string<> ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(string/= ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' != ''string2''
|[[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[JavaScript]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[D (programming language)|D]]
|-
|''string1'' \= ''string2''
|[[REXX (programming language)|REXX]]
|-
|''string1'' /= ''string2''
|[[Ada (programming language)|Ada]], [[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|test ''string1'' != ''string2'', or <br />[ ''string1'' != ''string2'' ]
|[[Bourne Shell]]
|-
|''string1'' -ne ''string2'', or <br />-not [string]::Equals(''string1'', ''string2'')
|[[Windows PowerShell]]
|}
<source lang="csharp">
// Example in C#
"hello" != "world" // returns true
</source>
<source lang="vb">
' Example in Visual Basic
"hello" <> "world" ' returns true
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -ne "world" # returns true
</source>
<!-- endsection -->
===index===
''see'' [[#Find]]
===indexof===
''see'' [[#Find]]
===instr===
''see'' [[#Find]]
===instrrev===
''see'' [[#rfind]]
===join===
{|
|- style="background:#fffeed;"
| Definition
| join(''separator'', ''list_of_strings'') joins a list of strings with a separator
|-
| Description
| Joins the list of strings into a new string, with the separator string between each of the substrings. Opposite of ''split''.
|-
| Related
| sprintf
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|std.string.join(''array_of_strings'', ''separator'')
|[[D (programming language)|D]]
|-
|join(''separator'', ''list_of_strings'')
|[[Perl]], [[PHP]]
|-
|implode(''separator'', ''array_of_strings'')
|[[PHP]]
|-
|''separator''.join(''sequence_of_strings'')
|[[Python (programming language)|Python]]
|-
|''array_of_strings''.join(''separator'')
|[[Ruby (programming language)|Ruby]], [[JavaScript]]
|-
|(string-join ''array_of_strings'' ''separator'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(format nil "~{~a~^''separator''~}" ''array_of_strings'')
|[[Common Lisp]]
|-
|String.concat ''separator'' ''list_of_strings''
|[[OCaml]]
|-
|String.concatWith ''separator'' ''list_of_strings''
|[[Standard ML]]
|-
|Data.List.intercalate ''separator'' ''list_of_strings''
|[[Haskell (programming language)|Haskell]] (GHC)
|-
|Join(''array_of_strings'', ''separator'')
|[[Visual Basic|VB]]
|-
|String.Join(''separator'', ''array_of_strings'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|&{$OFS=''$separator''; "''$array_of_strings''"}, or <br />''array_of_strings'' -join ''separator''
|[[Windows PowerShell]]
|-
|[''array_of_strings'' componentsJoinedByString:''separator'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
String.Join("-", {"a", "b", "c"}) // "a-b-c"
</source>
<source lang="python">
# Example in Python
"-".join(["a", "b", "c"]) # 'a-b-c'
</source>
<source lang="ruby">
# Example in Ruby
["a", "b", "c"].join("-") # 'a-b-c'
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-join '("a" "b" "c") "-") ; "a-b-c"
</source>
<!-- endsection -->
===lastindexof===
''see'' [[#rfind]]
===left===
{|
|- style="background:#fffeed;"
| Definition
| left(''string'',''n'') returns string
|-
| Description
| Returns the left ''n'' part of a string. If ''n'' is greater than the length of the string then most implementations return the whole string (exceptions exist - see code examples).
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string (string'First .. string'First + ''n'' - 1)
|[[Ada (programming language)|Ada]]
|-
|string:substr(''string'', ''start'', ''length'')
|[[Erlang (programming language)|Erlang]]
|-
|Left(''string'',''n'')
|[[Visual Basic|VB]]
|-
|left(''string'',''n'')
|[[Ingres (database)|Ingres]]
|-
|left(''string'',''n'' [,''padchar''])
|[[REXX (programming language)|REXX]], [[Erlang (programming language)|Erlang]]
|-
|substr(''string'', 0, ''n'')
|[[AWK]] (changes string), [[Perl]], [[PHP]]
|-
|''string''[:''n'']
|[[Python (programming language)|Python]]
|-
|''string''[0, ''n''] <br /> ''string''[0..''n'' - 1]
|[[Ruby (programming language)|Ruby]]
|-
|''string''.substr(0,''n'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|''string''[0 .. ''n'']
|[[D (programming language)|D]] (if n is largerer than length of string, then in Debug mode ArrayRangeException is thrown, in Release mode behaviour is unspecified, mostly Segmentation Fault)
|-
|''string''.Substring(0,''n'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|leftstr(''string'', ''n'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|-
|''string''.substring(0,''n'')
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|(string-take ''string'' ''n'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|take ''n'' ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' substringToIndex:''n'']
|[[Objective-C]] (<code>NSString *</code> only)
|-
|String.extract (''string'', ''n'', NONE)
|[[Standard ML]]
|-
|String.sub ''string'' 0 ''n''
|[[OCaml]] (if n is larger than length of string, raises Invalid_argument)
|-
|''string''.[..''n'']
|[[F Sharp (programming language)|F#]]
|}
<source lang="text">
/* Examples in REXX */
left("abcde", 3) /* returns "abc" */
left("abcde", 8) /* returns "abcde " */
left("abcde", 8, "*") /* returns "abcde***" */
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-take "abcde", 3) ; returns "abc"
(string-take "abcde", 8) ; error
</source>
<source lang="vb">
' Examples in Visual Basic
Left("sandroguidi", 3) ' returns "san"
Left("sandroguidi", 100) ' returns "sandroguidi"
</source>
<!-- endsection -->
===len===
''see'' [[#length]]
<!-- endsection -->
===length===
{|
|- style="background:#fffeed;"
| Definition
| length(''string'') returns an integer number
|-
| Description
| Returns the length of a string (not counting the [[null character|null terminator]] or any other of the string's internal structural information). An empty string returns a length of 0.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string'Length
|[[Ada (programming language)|Ada]]
|-
|UPB string
|[[ALGOL 68]]
|-
|length(''string'')
|[[Perl]], [[Ingres (database)|Ingres]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[REXX (programming language)|REXX]]
|-
|[[Len (programming)|len]](''string'')
|[[Python (programming language)|Python]]
|-
|length(''string''), string:len(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|[[Len (programming)|Len]](''string'')
|[[Visual Basic|VB]]
|-
|''string''.Length
||[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|''string''.size OR ''string''.length
|[[Ruby (programming language)|Ruby]]
|-
|[[strlen]](''string'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only), [[PHP]]
|-
|''string''.length()
|[[C++]] (<code>[[std::string]]</code> only), [[Java (programming language)|Java]]
|-
|''string''.length
|[[D (programming language)|D]]
|-
|''string''.length
|[[JavaScript]]
|-
|(string-length ''string'')
|[[Scheme (programming language)|Scheme]]
|-
|(length ''string'')
|[[Common Lisp]]
|-
|String.length ''string''
|[[OCaml]]
|-
|size ''string''
|[[Standard ML]]
|-
|length ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' length]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Examples in C#
"hello".Length; // returns 5
"".Length; // returns 0
</source>
<source lang="text">
# Examples in Erlang
string:len("hello"). % returns 5
string:len(""). % returns 0
</source>
<source lang="perl">
# Examples in Perl
length("hello"); # returns 5
length(""); # returns 0
</source>
<source lang="vb">
' Examples in Visual Basic
Len("hello") ' returns 5
Len("") ' returns 0
</source>
<!-- endsection -->
===locate===
''see'' [[#Find]]
<!-- endsection -->
===Lowercase===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| lowercase(''string'') returns string
|-
| Description
| Returns the string in lower case.
|-
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|LCase(''string'')
|[[Visual Basic|VB]]
|-
|lc(''string'')
|[[Perl]]
|-
|tolower(''char'')
|[[C programming language|C]] (operates on a single character)
|-
|std.string.tolower(''string'')
|[[D (programming language)|D]]
|-
|transform(''string''.begin(), ''string''.end(), ''result''.begin(), tolower)
|[[C++]] (<code>[[std::string]]</code> only, result is stored in string ''result'' which is at least as long as ''string'', and may or may not be ''string'' itself)
|-
|lowercase(''string'')
|[[Delphi programming language|Delphi]]
|-
|strtolower(''string'')
|[[PHP]]
|-
|[[echo (computing)|echo]] "string" <nowiki>|</nowiki> [[tr (program)|tr]] 'A-Z' 'a-z'
|[[Unix]]
|-
|''string''.lower()
|[[Python (programming language)|Python]]
|-
|''string''.downcase
|[[Ruby (programming language)|Ruby]]
|-
|(string-downcase ''string'')
|[[Scheme (programming language)|Scheme]] (R6RS), [[Common Lisp]]
|-
|String.lowercase ''string''
|[[OCaml]]
|-
|String.map Char.toLower ''string''
|[[Standard ML]]
|-
|map Char.toLower ''string''
|[[Haskell (programming language)|Haskell]]
|-
|''string''.toLowerCase()
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|to_lower(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|''string''.ToLower()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|[''string'' lowercaseString]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"Wiki means fast?".ToLower(); // "wiki means fast?"
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-downcase "Wiki means fast?") ; "wiki means fast?"
</source>
<source lang="vb">
' Example in Visual Basic
LCase("Wiki means fast?") ' "wiki means fast?"
</source>
<!-- endsection -->
===mid===
''see'' [[#substring]]
<!-- endsection -->
===partition===
{|
|- style="background:#fffeed;"
| Definition
| <string>.partition(''separator'') returns the sub-string before the separator; the separator; then the sub-string after the separator.
|-
| Description
| Splits the given string by the separator and returns the three substrings that together make the original.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string''.partition(''separator'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]](1.9+)
|-
|lists:partition(''pred'', ''string'')
|[[Erlang (programming language)|Erlang]]
|-
|}
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".partition('spam') # ('Spam eggs ', 'spam', ' spam and ham')
"Spam eggs spam spam and ham".partition('X') # ('Spam eggs spam spam and ham', "", "")
</source>
<!-- endsection -->
===replace===
{|
|- style="background:#fffeed;"
| Definition
| replace(''string'', ''find'', ''replace'') returns string
|-
| Description
| Returns a string the with ''find'' occurrences changed to ''replace''.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|changestr(''find'', ''string'', ''replace'')
|[[REXX (programming language)|REXX]]
|-
|std.string.replace(''string'', ''find'', ''replace'')
|[[D (programming language)|D]]
|-
|Replace(''string'', ''find'', ''replace'')
|[[Visual Basic|VB]]
|-
|''string''.Replace(''find'', ''replace'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|str_replace(''find'', ''replace'', ''string'')
|[[PHP]]
|-
|re:replace(''string'', ''find'', ''replace'', [{return, list}])
|[[Erlang (programming language)|Erlang]]
|-
|''string''.replace(''find'', ''replace'')
|[[Python (programming language)|Python]], [[Java (programming language)|Java]] (1.5+)
|-
|''string''.replaceAll(''find_regex'', ''replace'')<ref name="regex" />
|[[Java (programming language)|Java]]
|-
|''string''.gsub(''find'', ''replace'')
|[[Ruby (programming language)|Ruby]]
|-
|''string'' =~ s/''find_regex''/''replace''/g<ref name="regex">The "find" string in this construct is interpreted as a [[regular expression]]. Certain characters have special meaning in regular expressions. If you want to find a string literally, you need to quote the special characters.</ref>
|[[Perl]]
|-
|''string''.replace(''find'', ''replace'', "g") or<br /> ''string''.replace(/''find_regex''/g, ''replace'')<ref name="regex" />
|[[JavaScript]]
|-
|[[echo (computing)|echo]] "''string''" <nowiki>|</nowiki> [[sed]] 's/''find_regex''/''replace''/g'<ref name="regex" />
|[[Unix]]
|-
|''string''.replace(''find'', ''replace''), or<br />''string'' -replace ''find_regex'', ''replace''<ref name="regex" />
|[[Windows PowerShell]]
|-
|Str.global_replace (Str.regexp_string ''find'') ''replace'' ''string''
|[[OCaml]]
|-
|[''string'' stringByReplacingOccurrencesOfString:''find'' withString:''replace'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Examples in C#
"effffff".Replace("f", "jump"); // returns "ejumpjumpjumpjumpjumpjump"
"blah".Replace("z", "y"); // returns "blah"
</source>
<source lang="java5">
// Examples in Java
"effffff".replace("f", "jump"); // returns "ejumpjumpjumpjumpjumpjump"
"effffff".replaceAll("f*", "jump"); // returns "ejump"
</source>
<source lang="vb">
' Examples in Visual Basic
Replace("effffff", "f", "jump") ' returns "ejumpjumpjumpjumpjumpjump"
Replace("blah", "z", "y") ' returns "blah"
</source>
<source lang="text">
# Examples in Windows PowerShell
"effffff" -replace "f", "jump" # returns "ejumpjumpjumpjumpjumpjump"
"effffff" -replace "f*", "jump" # returns "ejump"
</source>
<!-- endsection -->
===reverse===
{|
|- style="background:#fffeed;"
| Definition
| reverse(''string'')
|-
| Description
| Reverses the order of the characters in the string.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|reverse ''string''
|[[Perl]], [[Haskell (programming language)|Haskell]]
|-
|lists:reverse(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|strrev(''string'')
|[[PHP]]
|-
|''string''[::-1]
|[[Python (programming language)|Python]]
|-
|(string-reverse ''string'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(reverse ''string'')
|[[Common Lisp]]
|-
|''string''.reverse
|[[Ruby (programming language)|Ruby]]
|-
|new StringBuilder(''string'').reverse().toString()
|[[Java (programming language)|Java]]
|-
|std::reverse(''string''.begin(), ''string''.end());
|[[C++]] (<code>[[std::string]]</code> only, modifies string)
|-
|StrReverse(''string'')
|[[Visual Basic|VB]]
|-
|''string''.Reverse().ToString()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]]
|-
|implode (rev (explode ''string''))
|[[Standard ML]]
|}
<source lang="perl">
# Example in Perl
reverse "hello" # returns "olleh"
</source>
<source lang="python">
# Example in Python
"hello"[::-1] # returns "olleh"
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-reverse "hello") ; returns "olleh"
</source>
<!-- endsection -->
===rfind===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| rfind(''string'',''substring'') returns integer
|-
| Description
| Returns the position of the start of the last occurrence of ''substring'' in ''string''. If the ''substring'' is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE.
|-
| Related
| instr
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|InStrRev([''startpos'', ]''string'',''substring'')
|[[Visual Basic|VB]]
|returns 0
|-
|rindex(''string'',''substring''[,''startpos''])
|[[Perl]]
|returns -1
|-
|strrpos(''string'',''substring''[,''startpos''])
|[[PHP]]
|returns FALSE
|-
|''string''.rfind(''substring''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|std.string.rfind(''string'', ''substring'')
|[[D (programming language)|D]]
|returns -1
|-
|''string''.rfind(''substring''[,''startpos''[, ''endpos'']])
|[[Python (programming language)|Python]]
|returns -1
|-
|''string''.rindex(''substring''[,''startpos''])
|[[Ruby (programming language)|Ruby]]
|returns nil
|-
|''string''.lastIndexOf(''substring''[,''startpos''])
|[[Java (programming language)|Java]], [[JavaScript]]
|returns -1
|-
|''string''.LastIndexOf(''substring''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|(search ''substring'' ''string'' :from-end)
|[[Common Lisp]]
|returns NIL
|-
|[''string'' rangeOfString:''substring'' options:NSBackwardsSearch].___location
|[[Objective-C]] (<code>NSString *</code> only)
|returns NSNotFound
|-
|Str.search_backward (Str.regexp_string ''substring'') ''string'' (Str.length ''string'' - 1)
|[[OCaml]]
|raises Not_found
|}
<source lang="lisp">
; Examples in Common Lisp
(search "e" "Hello mate" :from-end) ; returns 9
(search "z" "word" :from-end) ; returns NIL
</source>
<source lang="csharp">
// Examples in C#
"Hello mate".LastIndexOf("e"); // returns 9
"Hello mate".LastIndexOf("e", 4); // returns 1
"word".LastIndexOf("z"); // returns -1
</source>
<source lang="vb">
' Examples in Visual Basic
InStrRev("Hello mate", "e") ' returns 10
InStrRev(5, "Hello mate", "e") ' returns 2
InStrRev("word", "z") ' returns 0
</source>
<!-- endsection -->
===right===
{|
|- style="background:#fffeed;"
| Definition
| right(''string'',''n'') returns string
|-
| Description
| Returns the right ''n'' part of a string. If ''n'' is greater than the length of the string then most implementations return the whole string (exceptions exist - see code examples).
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string (string'Last - ''n'' + 1 .. string'Last)
|[[Ada (programming language)|Ada]]
|-
|Right(''string'',''n'')
|[[Visual Basic|VB]]
|-
|right(''string'',''n'')
|[[Ingres (database)|Ingres]]
|-
|''string''.substring(''string''.length()-''n'', ''string''.length())
|[[Java (programming language)|Java]]
|-
|right(''string'',''n'' [,''padchar''])
|[[REXX (programming language)|REXX]], [[Erlang (programming language)|Erlang]]
|-
|substr(''string'',-''n'')
|[[Perl]], [[PHP]]
|-
| ''string''[-''n'':]
|[[Python (programming language)|Python]]
|-
|(string-take-right ''string'' ''n'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|''string''[-''n''..-1]
|[[Ruby (programming language)|Ruby]]
|-
|''string''[$-n .. $]
|[[D (programming language)|D]] (if n is larger than length of string, then in Debug mode ArrayRangeException is thrown, and unspecified behaviour in Release mode)
|-
|String.sub ''string'' (String.length ''string'' - ''n'') ''n''
|[[OCaml]] (if n is larger than length of string, raises Invalid_argument)
|}
<source lang="text">
/* Examples in REXX */
right("abcde", 3) /* returns "cde" */
right("abcde", 8) /* returns " abcde" */
right("abcde", 8, "*") /* returns "***abcde" */
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-take-right "abcde", 3) ; returns "cde"
(string-take-right "abcde", 8) ; error
</source>
<source lang="vb">
' Examples in Visual Basic
Right("sandroguidi", 3) ' returns "idi"
Right("sandroguidi", 100) ' returns "sandroguidi"
</source>
<source lang="java">
// Examples in Java; extract rightmost 4 characters
String str = "CarDoor";
str.substring(str.length()-4, str.length()); // returns 'Door'
</source>
<!-- endsection -->
===rpartition===
{|
|- style="background:#fffeed;"
| Definition
| <string>.rpartition(''separator'') Searches for the separator from right-to-left within the string then returns the sub-string before the separator; the separator; then the sub-string after the separator.
|-
| Description
| Splits the given string by the right-most separator and returns the three substrings that together make the original.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string''.rpartition(''separator'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|}
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".rpartition('spam') ### ('Spam eggs spam ', 'spam', ' and ham')
"Spam eggs spam spam and ham".rpartition('X') ### ("", "", 'Spam eggs spam spam and ham')
</source>
<!-- endsection -->
===slice===
''see'' [[#substring]]
<!-- endsection -->
===split===
{|
|- style="background:#fffeed;"
| Definition
| <string>.split(''separator''[, ''limit'']) splits a string on separator, optionally only up to a limited number of substrings
|-
| Description
| Splits the given string by occurrences of the separator (itself a string) and returns a list (or array) of the substrings. If ''limit'' is given, after ''limit'' - 1 separators have been read, the rest of the string is made into the last substring, regardless of whether it has any separators in it. The Scheme and Erlang implementations are similar but differ in several ways. Opposite of ''join''.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|split(/''separator''/, ''string''[, ''limit''])
|[[Perl]]
|-
|explode(''separator'', ''string''[, ''limit''])
|[[PHP]]
|-
|''string''.split(''separator''[, ''limit''])
|[[Javascript]], [[Java (programming language)|Java]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|-
|string:tokens(''string'', ''sepchars'')
|[[Erlang (programming language)|Erlang]]
|-
|(string-tokenize ''string''[ ''charset''[ ''start''[ ''end'']]])
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|Split(''string'', ''sepchars''[, ''limit''])
|[[Visual Basic|VB]]
|-
|''string''.Split(''sepchars''[, ''limit''[, ''options'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|''string'' -split ''separator''[, ''limit''[, ''options'']]
|[[Windows PowerShell]]
|-
|Str.split (Str.regexp_string ''separator'') ''string''
|[[OCaml]]
|-
|std.string.split(''string'', ''separator'')
|[[D (programming language)|D]]
|-
|[''string'' componentsSeparatedByString:''separator'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"abc,defgh,ijk".Split(','); // {"abc", "defgh", "ijk"}
"abc,defgh;ijk".Split(',', ';'); // {"abc", "defgh", "ijk"}
</source>
<source lang="text">
% Example in Erlang
string:tokens("abc;defgh;ijk", ";"). % ["abc", "defgh", "ijk"]
</source>
<source lang="java">
// Examples in Java
"abc,defgh,ijk".split(','); // {"abc", "defgh", "ijk"}
"abc,defgh;ijk".split(',|;'); // {"abc", "defgh", "ijk"}
</source>
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".split('spam') # ['Spam eggs ', ' ', ' and ham']
"Spam eggs spam spam and ham".split('X') # ['Spam eggs spam spam and ham']
</source>
<!-- endsection -->
===sprintf===
''see'' [[#Format]]
===strip===
''see'' [[#trim]]
<!-- endsection -->
===strcmp===
''see'' [[#Compare (integer result)]]
<!-- endsection -->
===substring===
{|
|- style="background:#fffeed;"
| Definition
| substring(''string'', ''startpos'', ''endpos'') returns string <br /> substr(''string'', ''startpos'', ''numChars'') returns string
|-
| Description
| Returns a substring of ''string'' between starting at ''startpos'' and ''endpos'', or starting at ''startpos'' of length ''numChars''. The resulting string is truncated if there are fewer than ''numChars'' characters beyond the starting point. ''endpos'' represents the index after the last character in the substring.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string[''startpos'':''endpos'']
|[[ALGOL 68]] (changes base index)
|-
|string (''startpos'' .. ''endpos'')
|[[Ada (programming language)|Ada]] (changes base index)
|-
|Mid(''string'', ''startpos'', ''numChars'')
|[[Visual Basic|VB]]
|-
|substr(''string'', ''startpos'', ''numChars'')
|[[AWK]] (changes string), [[Perl]]<sup>1,3</sup>, [[PHP]]<sup>1,3</sup>
|-
|substr(''string'', ''startpos'' [,''numChars'', ''padChar''])
|[[REXX (programming language)|REXX]]
|-
|''string''[''startpos'':''endpos'']
|[[Python (programming language)|Python]]<sup>1,2</sup>
|-
|''string''[''startpos'', ''numChars''] <br /> ''string''[''startpos'' .. ''endpos''-1] <br /> ''string''[''startpos'' ... ''endpos'']
|[[Ruby (programming language)|Ruby]]<sup>1,2</sup>
|-
|''string''.slice(''startpos'', ''endpos'')
|[[JavaScript]]
|-
|''string''.substr(''startpos'', ''numChars'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|''string''.Substring(''startpos'', ''numChars'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|''string''.substring(''startpos'', ''endpos'')
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|copy(''string'', ''startpos'', ''numChars'')
|[[Delphi programming language|Delphi]]
|-
|(substring ''string'' ''startpos'' ''endpos'')
|[[Scheme programming language|Scheme]]
|-
|(subseq ''string'' ''startpos'' ''endpos'')
|[[Common Lisp]]
|-
|String.sub ''string'' ''startpos'' ''numChars''
|[[Ocaml]]
|-
|substring (''string'', ''startpos'', ''numChars'')
|[[Standard ML]]
|-
|string:sub_string(''string'', ''startpos'', ''endpos'')<br />string:substr(''string'', ''startpos'', ''numChars'')
|[[Erlang programming language|Erlang]]
|-
|char ''result''[''numChars''+1] = "";<br />strncat(''result'', ''string'' + ''startpos'', ''numChars'');
|[[C programming language|C]]
|-
|''string''[''startpos .. ''endpos''+1)
|[[D (programming language)|D]]
|-
|take ''numChars'' $ drop ''startpos'' ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' substringWithRange:NSMakeRange(''startpos'', ''numChars'')]
|[[Objective-C]] (<code>NSString *</code> only)
|-
|''string''.[''startpos''..''endpos'']
|[[F Sharp (programming language)|F#]]
|}
# In this language, ''startpos'' can be negative, which indicates to start that number of places before the end of the string.
# In this language, ''endpos'' can be negative, which indicates to end that number of places before the end of the string.
# In this language, ''numChars'' can be negative, which indicates to end that number of places before the end of the string.
<source lang="csharp">
// Examples in C#
"abc".Substring(1, 1): // returns "b"
"abc".Substring(1, 2); // returns "bc"
"abc".Substring(1, 6); // error
</source>
<source lang="text">
% Examples in Erlang
string:substr("abc", 2, 1). % returns "b"
string:substr("abc", 2). % returns "bc"
</source>
<source lang="python">
# Examples in Python
"abc"[1:1] # returns "b"
"abc"[1:2] # returns "bc"
</source>
<source lang="text">
/* Examples in REXX */
substr("abc", 2, 1) /* returns "b" */
substr("abc", 2) /* returns "bc" */
substr("abc", 2, 6) /* returns "bc " */
substr("abc", 2, 6, "*") /* returns "bc****" */
</source>
<!-- endsection -->
===Uppercase===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| uppercase(''string'') returns string
|-
| Description
| Returns the string in upper case.
|-
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|UCase(''string'')
|[[Visual Basic|VB]]
|-
|toupper(''string'')
|[[AWK]] (changes string)
|-
|uc(''string'')
|[[Perl]]
|-
|toupper(''char'')
|[[C programming language|C]] (operates on a single character)
|-
|std.string.toupper(''string'')
|[[D (programming language)|D]]
|-
|transform(''string''.begin(), ''string''.end(), ''result''.begin(), toupper)
|[[C++]] (<code>[[std::string]]</code> only, result is stored in string ''result'' which is at least as long as ''string'', and may or may not be ''string'' itself)
|-
|uppercase(''string'')
|[[Delphi programming language|Delphi]]
|-
|strtoupper(''string'')
|[[PHP]]
|-
|[[echo (computing)|echo]] "string" <nowiki>|</nowiki> [[tr (program)|tr]] 'a-z' 'A-Z'
|[[Unix]]
|-
|translate(''string'')
|[[REXX (programming language)|REXX]]
|-
|''string''.upper()
|[[Python (programming language)|Python]]
|-
|''string''.upcase
|[[Ruby (programming language)|Ruby]]
|-
|(string-upcase ''string'')
|[[Scheme (programming language)|Scheme]], [[Common Lisp]]
|-
|String.uppercase ''string''
|[[OCaml]]
|-
|String.map Char.toUpper ''string''
|[[Standard ML]]
|-
|map Char.toUpper ''string''
|[[Haskell (programming language)|Haskell]]
|-
|''string''.toUpperCase()
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|to_upper(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|''string''.ToUpper()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|[''string'' uppercaseString]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"Wiki means fast?".ToUpper(); // "WIKI MEANS FAST?"
</source>
<source lang="text">
/* Example in REXX */
translate("Wiki means fast?") /* "WIKI MEANS FAST?" */
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-upcase "Wiki means fast?") ; "WIKI MEANS FAST?"
</source>
<source lang="vb">
' Example in Visual Basic
UCase("Wiki means fast?") ' "WIKI MEANS FAST?"
</source>
<!-- endsection -->
===trim===
{{main|Trim (programming)}}
'''trim''' or '''strip''' is used to remove whitespace from the beginning, end, or both beginning and end, of a string.
== Notes ==
{{reflist}}
== External links ==
*[http://perldoc.perl.org/index-functions-by-cat.html#Functions-for-SCALARs-or-strings Perl String Functions]
*[http://docs.python.org/lib/string-methods.html Python String Methods]
*[http://srfi.schemers.org/srfi-13/srfi-13.html Scheme String Procedures]
*[http://www.erlang.org//doc/man/string.html Erlang String Functions]
*[http://www.and.org/ustr/ The Ustr String Library]
*[http://msdn2.microsoft.com/en-us/library/system.string_members.aspx .NET String Methods and Properties]
*[http://www.ruby-doc.org/core-1.8.7/classes/String.html Ruby String Class]
*[http://www.php.net/manual/en/ref.strings.php PHP String functions]
*{{javadoc:SE|java/lang|String|package=java.lang}} members
*[http://www.string-functions.com/ Online String Manipulation Tools]
*[http://haskell.org/ghc/docs/latest/html/libraries/ Haskell Hierarchical Libraries]
*[http://www.digitalmars.com/d/2.0/phobos/std_string.html std.string from Phobos (D standard library)]
*[http://academicearth.org/lectures/string-processing Stanford Computer Science lecture on string processing]
[[Category:Programming language comparisons]]
[[Category:Articles with example Python code]]
[[es:Sustitución (informática teórica)]]' |
New page wikitext, after the edit (new_wikitext ) | '{{redirect|String functions|string functions in formal language theory|String operations}}
<!--
##################################
A NOTE TO CONTRIBUTORS:
Thanks to all who have submitted code samples from various programming languages.
When adding code samples, *please* do not include extraneous characters and symbols
that are not a part of the programming language itself (such as interactive command
prompts). This causes unnecessary confusion for general readers.
The code examples should at least be able to compile without errors when directly cut
and pasted into a source code file.
##################################
-->
{{ProgLangCompare}}
String [[Function (computer science)|functions]] are used in computer [[programming language]]s to manipulate a [[String (computer science)|string]] or query information about a string (some do both).
Most computer programming languages that have a string [[datatype]] will have some string functions although there may be other low level ways within each language to handle strings directly. In object oriented languages, string functions are often implemented as properties and methods of string objects. In functional and list based languages a string is represented as a list (of character codes), therefore all list-manipulation procedures could be considered string functions. However such languages may implement a subset of explicit string-specific functions as well.
The most basic example of a string function is the ''length(string)'' function. This function returns the length of a [[string literal]].
:eg. ''length("hello world")'' would return 11.
Other languages may have string functions with similar or exactly the same syntax or parameters or outcomes. For example in many languages the length function is usually represented as ''[[Len (programming)|len]](string)''. The below list of common functions aims to help limit this confusion.
==Common String Functions (multi language reference)==
Here is a list of common string functions which are found in other languages. Any other equivalent functions used by other languages are also listed. The below list of common functions aims to help programmers find the equivalent function in a language. Note, string [[concatenation]] and [[regular expressions]] are handled in separate pages.
<!-- When giving literal examples please say the language you are using as different languages use different syntax. please list in alpha order. -->
===CharAt===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| charAt(string,integer) returns character.
|-
| Description
| Returns character at index in the string.
|-
| Equivalent
| See [[#substring|substring]] of length 1 character.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! Base index
|-
|''string''[''i'']
|[[ALGOL 68]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|1
|-
|''string''[''i'']
|[[C (programming language)|C]], [[C++]], [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[Python (programming language)|Python]]<sup>1</sup>, [[PHP]], [[Ruby (programming language)|Ruby]]<sup>1</sup>, [[Windows PowerShell]]
|0
|-
|''string''(''i'')
|[[Ada (programming language)|Ada]]
|≥1
|-
|Mid(''string'',i,1)
|[[Visual Basic|VB]]
|1
|-
|''string''.Chars(''i'')
|[[Visual Basic .NET|VB.NET]]
|0
|-
|''string''.charAt(''i'')
|[[Java (programming language)|Java]], [[JavaScript]]
|0
|-
|''string''.[''i'']
|[[OCaml]], [[F Sharp (programming language)|F#]]
|0
|-
|String.sub (''string'', ''i'')
|[[Standard ML]]
|0
|-
|''string'' !! ''i''
|[[Haskell (programming language)|Haskell]]
|0
|-
|(string-ref ''string'' ''i'')
|[[Scheme (programming language)|Scheme]]
|0
|-
|(char ''string'' ''i'')
|[[Common Lisp]]
|0
|-
|substr(''string'', ''i'', 1)
|[[Perl]]<sup>1</sup>
|0
|-
|''string''.at(''i'')
|[[C++]] (<code>[[std::string]]</code> only) (w/ bounds checking)
|0
|-
|string:substr(''string'', ''i'', 1)
|[[Erlang (programming language)|Erlang]]
|1
|-
|[''string'' characterAtIndex:''i'']
|[[Objective-C]] (<code>NSString *</code> only)
|0
|}
# In this language, the index can be negative, which then indicates the number of places before the end of the string.
<pre>
# Example in ALGOL 68 #
"Hello, World"[2]; // 'e'
</pre>
<source lang="csharp">
// Example in C#
"Hello, World"[2]; // 'l'
</source>
<source lang="python">
# Examples in Python
"Hello, World"[2] # 'l'
"Hello, World"[-3] # 'r'
</source>
<source lang="vb">
' Example in Visual Basic
GetChar("Hello, World", 2) ' "e"
</source>
<source lang="vbnet">
' Example in Visual Basic .NET
"Hello, World".Chars(2) ' "l"c
</source>
<!-- endsection -->
===Compare (integer result)===
{|
|- style="background:#fffeed;"
| Definition
| compare(string1,string2) returns integer.
|-
| Description
| Compares two strings to each other. If they are equivalent, a zero is returned. Otherwise, most of these routines will return a positive or negative result corresponding to whether string1 is [[lexicographical order|lexicographically]] greater than, or less than, respectively, than string2. The exceptions are the Scheme and REXX routines which return the index of the first mismatch.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|
IF ''string1''<''string2'' THEN -1 ELSE ABS (''string1''>''string2'') FI
|[[ALGOL 68]]
|-
|cmp(''string1'', ''string2'')
|[[Python (programming language)|Python]]
|-
|[[strcmp]](''string1'', ''string2'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only), [[PHP]]
|-
|std.string.cmp(''string1'', ''string2'')
|[[D (programming language)|D]]
|-
|StrComp(''string1'', ''string2'')
|[[Visual Basic|VB]]
|-
|''string1'' cmp ''string2''
|[[Perl]]
|-
|''string1'' <=> ''string2''
|[[Ruby (programming language)|Ruby]]
|-
|''string1''.compare(''string2'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|compare(''string1'', ''string2'')
|[[REXX (programming language)|REXX]]
|-
|CompareStr(''string1'', ''string2'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|-
|''string1''.compareTo(''string2'')
|[[Java (programming language)|Java]]
|-
|''string1''.CompareTo(''string2'')
|[[Visual Basic .Net|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|(string-compare ''string1'' ''string2'' ''p<'' ''p='' ''p>'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|compare ''string1'' ''string2''
|[[OCaml]]
|-
|String.compare (''string1'', ''string2'')
|[[Standard ML]] (returns LESS, EQUAL, or GREATER)
|-
|compare ''string1'' ''string2''
|[[Haskell (programming language)|Haskell]] (returns LT, EQ, or GT)
|-
|[string]::Compare(''string1'', ''string2'')
|[[Windows PowerShell]]
|-
|[''string1'' compare:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="python">
# Example in Python
cmp("hello", "world") # returns -1
</source>
<source lang="text">
/** Example in REXX */
compare("hello", "world") /* returns index of mismatch: 1 */
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
; returns index of mismatch: 0
(string-compare "hello" "world" values values values)
</source>
<!-- endsection -->
===Compare (relational operator-based, Boolean result)===
{|
|- style="background:#fffeed;"
| Definition
| string1 op string2 OR (compare string1 string2) returns Boolean.
|-
| Description
| [[lexicographical order|Lexicographically]] compares two strings using a relational operator or function. Boolean result returned.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' op ''string2'', where op can be any of =, <>, <, >, <= and >=
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[OCaml]], [[Standard ML]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]], [[F Sharp (programming language)|F#]]
|-
|''string1'' op ''string2'', where op can be any of =, /=, ≠, <, >, <=, ≤ and ≥; Also: EQ, NE, LT, LE, GE and GT
|[[ALGOL 68]]
|-
|(stringX? ''string1'' ''string2''), where X can be any of =, -ci=, <, -ci<, >, -ci>, <=, -ci<=, >= and -ci>= (operators starting with '-ci' are case-insensitive)
|[[Scheme (programming language)|Scheme]]
|-
|(stringX ''string1'' ''string2''), where X can be any of =, -ci=, <>, -ci<>, <, -ci<, >, -ci>, <=, -ci<=, >= and -ci>= (operators starting with '-ci' are case-insensitive)
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(stringX ''string1'' ''string2''), where X can be any of =, -equal, /=, -not-equal, <, -lessp, >, -greaterp, <=, -not-greaterp, >= and -not-lessp (the verbal operators are case-insensitive)
|[[Common Lisp]]
|-
|''string1'' op ''string2'', where op can be any of =, \=, <, >, <= and >=
|[[REXX (programming language)|REXX]]
|-
|''string1'' op ''string2'', where op can be any of =, /=, <, >, <= and >=
|[[Ada (programming language)|Ada]]
|-
|''string1'' op ''string2'', where op can be any of ==, /=, <, >, =< and >=
|[[Erlang (programming language)|Erlang]]
|-
|''string1'' op ''string2'', where op can be any of ==, /=, <, >, <= and >=
|[[Haskell (programming language)|Haskell]]
|-
|''string1'' op ''string2'', where op can be any of ''eq'', ''ne'', ''lt'', ''gt'', ''le'' and ''ge''
|[[Perl]]
|-
|''string1'' op ''string2'', where op can be any of ==, !=, <, >, <= and >=
|[[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[JavaScript]], [[Python (programming language)|Python]], [[PHP]], [[Ruby (programming language)|Ruby]]
|-
|''string1'' op ''string2'', where op can be any of -eq, -ceq, -ne, -cne, -lt, -clt, -gt, -cgt, -le, -cle, -ge, and -cge (operators starting with 'c' are case-sensitive)
|[[Windows PowerShell]]
|}
<source lang="text">
% Example in Erlang
"hello" > "world". % returns false
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -gt "world" # returns false
</source>
<!-- endsection -->
===Concatenation===
{{main|Concatenation}}
{|
|- style="background:#fffeed;"
| Definition
| concatenate(string1,string2) returns string.
|-
| Description
| Concatenates (joins) two strings to each other, returning the combined string. Note that some languages like C have mutable strings, so really the second string is being appended to the first string and the mutated string is returned.
|}
<!-- table is missing entries for sh -->
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' & ''string2''
|[[Ada (programming language)|Ada]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]]
|-
|strcat(''string1'', ''string2'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only; modifies ''string1'', which must have enough space to store the result)
|-
|''string1'' . ''string2''
|[[Perl]], [[PHP]]
|-
|''string1'' + ''string2''
|[[ALGOL 68]], [[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[Java (programming language)|Java]], [[JavaScript]], [[Windows PowerShell]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[F Sharp (programming language)|F#]], [[Turing (Programming language)|Turing]]
|-
|''string1'' ~ ''string2''
|[[D (programming language)|D]]
|-
|(string-append ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]]
|-
|(concatenate 'string ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' <nowiki>||</nowiki> ''string2''
|[[REXX (programming language)|REXX]], [[Fortran]]
|-
|''string1'' ++ ''string2''
|[[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|''string1'' ^ ''string2''
|[[OCaml]], [[Standard ML]], [[F Sharp (programming language)|F#]]
|-
|[''string1'' stringByAppendingString:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"abc" + "def"; // returns "abcdef"
</source>
<source lang="vb">
' Example in Visual Basic
"abc" & "def" ' returns "abcdef"
</source>
<source lang="d">
// Example in D
"abc" ~ "def"; // returns "abcdef"
</source>
<!-- endsection -->
===Equality===
<!-- startsection -->
Tests if two strings are equal. See also [[#Compare (relational operator-based, Boolean result)|#Compare]] and [[#Compare (integer result)|#Compare]]. Note that doing equality checks via. a generic [[#Compare (integer result)|Compare with integer result]] is not only confusing for the programer but is often a significantly more expensive operation, this is especially true when using "[[String (computer science)#Representations|C-strings]]".
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' == ''string2''
|[[Python (programming language)|Python]], [[C++]](<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[JavaScript]] [[PHP]], [[Ruby (programming language)|Ruby]], [[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|strcmp(''string1'', ''string2'') == 0
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only)
|-
|''string1'' == ''string2''
|[[D (programming language)|D]]
|-
|(string=? ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]]
|-
|(string= ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' = ''string2''
|[[ALGOL 68]], [[Ada (programming language)|Ada]], [[Object Pascal]] (Delphi), [[OCaml]], [[Pascal (programming language)|Pascal]], [[REXX programming language|REXX]], [[Standard ML]], [[Visual Basic|VB]], [[Visual Basic .NET|VB .NET]], [[F Sharp (programming language)|F#]]
|-
|test ''string1'' = ''string2'', or <br />[ ''string1'' = ''string2'' ]
|[[Bourne Shell]]
|-
|''string1'' eq ''string2''
|[[Perl]]
|-
|''string1''.equals(''string2'')
|[[Java (programming language)|Java]]
|-
|''string1'' -eq ''string2'', or <br />[string]::Equals(''string1'', ''string2'')
|[[Windows PowerShell]]
|-
|[''string1'' isEqualToString:''string2''], or <br />[''string1'' isEqual:''string2'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"hello" == "world" // returns false
</source>
<source lang="vb">
' Example in Visual Basic
"hello" = "world" ' returns false
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -eq "world" # returns false
</source>
<!-- endsection -->
===Find===
{|
|- style="background:#fffeed;"
| Definition
| find(''string'',''substring'') returns integer
|-
| Description
| Returns the position of the start of the first occurrence of ''substring'' in ''string''. If the ''substring'' is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE.
|-
| Related
| instrrev
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|string in string(substring, pos, ''string[startpos:]'')
|[[ALGOL 68]]
|returns BOOL: TRUE or FALSE, and position in REF INT pos.
|-
|InStr([''startpos'',]''string'',''substring'')
|[[Visual Basic|VB]] (positions start at 1)
|returns 0
|-
|index(''string'',''substring'')
|[[AWK]]
|returns 0
|-
|index(''string'',''substring''[,''startpos''])
|[[Perl]]
|returns -1
|-
|strpos(''string'',''substring''[,''startpos''])
|[[PHP]]
|returns FALSE
|-
|locate(''string'', ''substring'')
|[[Ingres (database)|Ingres]]
|returns string length + 1
|-
|strstr(''string'', ''substring'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only, returns pointer to first character)
|returns NULL
|-
|std.string.find(''string'', ''substring'')
|[[D (programming language)|D]]
|returns -1
|-
|pos(''substring'', ''string'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|returns 0
|-
|pos(''substring'', ''string''[,''startpos''])
|[[REXX (programming language)|REXX]]
|returns 0
|-
|''string''.find(''substring''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|''string''.find(''substring''[,''startpos''[,''endpos'']])
|[[Python (programming language)|Python]]
|returns -1
|-
|''string''.index(''substring''[,''startpos''])
|[[Ruby (programming language)|Ruby]]
|returns nil
|-
|''string''.indexOf(''substring''[,''startpos''])
|[[Java (programming language)|Java]], [[JavaScript]]
|returns -1
|-
|''string''.IndexOf(''substring''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|string:str(''string'', ''substring'')
|[[Erlang (programming language)|Erlang]]
|returns 0
|-
|(string-contains ''string'' ''substring'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|returns #f
|-
|(search ''substring'' ''string'')
|[[Common Lisp]]
|returns NIL
|-
|List.findIndex (List.isPrefixOf ''substring'') (List.tails ''string'')
|[[Haskell (programming language)|Haskell]] (returns Just ''index'')
|returns Nothing
|-
|Str.search_forward (Str.regexp_string ''substring'') ''string'' 0
|[[OCaml]]
|raises Not_found
|-
|Substring.size (#1 (Substring.position ''substring'' (Substring.full ''string'')))
|[[Standard ML]]
|returns string length
|-
|[''string'' rangeOfString:''substring''].___location
|[[Objective-C]] (<code>NSString *</code> only)
|returns NSNotFound
|}
<source lang="lisp">
; Examples in Common Lisp
(search "e" "Hello mate") ; returns 1
(search "z" "word") ; returns NIL
</source>
<source lang="csharp">
// Examples in C#
"Hello mate".IndexOf("e"); // returns 1
"Hello mate".IndexOf("e", 4); // returns 9
"word".IndexOf("z"); // returns -1
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-contains "Hello mate" "e") ; returns 1
(string-contains "word" "z") ; returns #f
</source>
<source lang="vb">
' Examples in Visual Basic
InStr("Hello mate", "e") ' returns 2
InStr(5, "Hello mate", "e") ' returns 10
InStr("word", "z") ' returns 0
</source>
<!-- endsection -->
===Find character===
{|
|- style="background:#fffeed;"
| Definition
| find character(''string'',''char'') returns integer
|-
| Description
| Returns the position of the start of the first occurrence of the character ''char'' in ''string''. If the character is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE. This can be accomplished as a special case of [[#Find]], with a string of one character; but it may be simpler or more efficient in many languages to locate just a single character. Also, in many languages, characters and strings are different types, so it is convenient to have such a function.
|-
| Related
| find
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|char in string(char, pos, ''string[startpos:]'')
|[[ALGOL 68]]
|returns BOOL: TRUE or FALSE, and position in REF INT pos.
|-
|strchr(''string'',''char'')
|[[C (programming language)|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only, returns pointer to character)
|returns NULL
|-
|std.string.find(''string'', ''dchar'')
|[[D (programming language)|D]]
|returns -1
|-
|''string''.find(''char''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|''string''.indexOf(''char''[,''startpos''])
|[[Java (programming language)|Java]]
|returns -1
|-
|''string''.IndexOf(''char''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|(position ''char'' ''string'')
|[[Common Lisp]]
|returns NIL
|-
|List.elemIndex ''char'' ''string''
|[[Haskell (programming language)|Haskell]] (returns Just ''index'')
|returns Nothing
|-
|String.index ''string'' ''char''
|[[OCaml]]
|raises Not_found
|}
<source lang="csharp">
// Examples in C#
"Hello mate".IndexOf('e'); // returns 1
"word".IndexOf('z') // returns -1
</source>
<source lang="lisp">
; Examples in Common Lisp
(position #\e "Hello mate") ; returns 1
(position #\z "word") ; returns NIL
</source>
<!-- endsection -->
===Format===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| format(''formatstring'', ''items'') returns string
|-
| Description
| Returns the formatted string representation of one or more items. See [[printf#sprintf|sprintf]] for more information.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|associate(''file'', ''string''); [[putf]](''file'', ''$formatstring$'', ''items'')
|[[ALGOL 68]]
|-
|Format(''item'', ''formatstring'')
|[[Visual Basic|VB]]
|-
|[[sprintf]](''formatstring'', ''items'')
|[[Perl]], [[PHP]], [[Ruby (programming language)|Ruby]]
|-
|io_lib:format(''formatstring'', ''items'')
|[[Erlang (programming language)|Erlang]]
|-
|[[sprintf]](''outputstring'', ''formatstring'', ''items'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only)
|-
|std.string.format(''formatstring'', ''items'')
|[[D (programming language)|D]]
|-
|[[printf]] -v ''outputstring'' ''formatstring'' ''items''
|[[Unix]]
|-
|''formatstring'' % (''items'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|-
|''formatstring''.format(''items'')
|Python 3.x (format specification is different from printf)
|-
|Printf.sprintf ''formatstring'' ''items''
|[[OCaml]], [[F Sharp (programming language)|F#]]
|-
|Text.Printf.printf ''formatstring'' ''items''
|[[Haskell (programming language)|Haskell]] (GHC)
|-
|String.format(''formatstring'', ''items'')
|[[Java (programming language)|Java]]
|-
|String.Format(''formatstring'', ''items'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|(format ''formatstring'' ''items'')
|[[Scheme (programming language)|Scheme]] (SRFI 28)
|-
|(format nil ''formatstring'' ''items'')
|[[Common Lisp]]
|-
|''formatstring'' -f ''items''
|[[Windows PowerShell]]
|-
|[NSString stringWithFormat:''formatstring'', ''items'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
String.Format("My {0} costs {1:C2}", "pen", 19.99); // returns "My pen costs $19.99"
</source>
<source lang="java5">
// Example in Java
String.format("My %s costs $%2f", "pen", 19.99); // returns "My pen costs $19.99"
</source>
<source lang="perl">
# Example in Perl
sprintf("My %s costs $%2f", "pen", 19.99); # returns "My pen costs $19.99"
</source>
<source lang="Scheme">
; Example in Scheme
(format "My ~a costs $~1,2F" "pen" 19.99) ; returns "My pen costs $19.99"
</source>
<!-- endsection -->
===Inequality===
<!-- startsection -->
Tests if two strings are not equal. See also [[#Equality]].
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string1'' <> ''string2''
|[[Visual Basic|VB]],[[Visual Basic .NET|VB .NET]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[OCaml]], [[Standard ML]], [[F Sharp (programming language)|F#]]
|-
|''string1'' ne ''string2''
|[[Perl]]
|-
|(string<> ''string1'' ''string2'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(string/= ''string1'' ''string2'')
|[[Common Lisp]]
|-
|''string1'' != ''string2''
|[[C++]] (<code>[[std::string]]</code> only), [[C Sharp (programming language)|C#]], [[JavaScript]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[D (programming language)|D]]
|-
|''string1'' \= ''string2''
|[[REXX (programming language)|REXX]]
|-
|''string1'' /= ''string2''
|[[Ada (programming language)|Ada]], [[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]]
|-
|test ''string1'' != ''string2'', or <br />[ ''string1'' != ''string2'' ]
|[[Bourne Shell]]
|-
|''string1'' -ne ''string2'', or <br />-not [string]::Equals(''string1'', ''string2'')
|[[Windows PowerShell]]
|}
<source lang="csharp">
// Example in C#
"hello" != "world" // returns true
</source>
<source lang="vb">
' Example in Visual Basic
"hello" <> "world" ' returns true
</source>
<source lang="text">
# Example in Windows PowerShell
"hello" -ne "world" # returns true
</source>
<!-- endsection -->
===index===
''see'' [[#Find]]
===indexof===
''see'' [[#Find]]
===instr===
''see'' [[#Find]]
===instrrev===
''see'' [[#rfind]]
===join===
{|
|- style="background:#fffeed;"
| Definition
| join(''separator'', ''list_of_strings'') joins a list of strings with a separator
|-
| Description
| Joins the list of strings into a new string, with the separator string between each of the substrings. Opposite of ''split''.
|-
| Related
| sprintf
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|std.string.join(''array_of_strings'', ''separator'')
|[[D (programming language)|D]]
|-
|join(''separator'', ''list_of_strings'')
|[[Perl]], [[PHP]]
|-
|implode(''separator'', ''array_of_strings'')
|[[PHP]]
|-
|''separator''.join(''sequence_of_strings'')
|[[Python (programming language)|Python]]
|-
|''array_of_strings''.join(''separator'')
|[[Ruby (programming language)|Ruby]], [[JavaScript]]
|-
|(string-join ''array_of_strings'' ''separator'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(format nil "~{~a~^''separator''~}" ''array_of_strings'')
|[[Common Lisp]]
|-
|String.concat ''separator'' ''list_of_strings''
|[[OCaml]]
|-
|String.concatWith ''separator'' ''list_of_strings''
|[[Standard ML]]
|-
|Data.List.intercalate ''separator'' ''list_of_strings''
|[[Haskell (programming language)|Haskell]] (GHC)
|-
|Join(''array_of_strings'', ''separator'')
|[[Visual Basic|VB]]
|-
|String.Join(''separator'', ''array_of_strings'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|&{$OFS=''$separator''; "''$array_of_strings''"}, or <br />''array_of_strings'' -join ''separator''
|[[Windows PowerShell]]
|-
|[''array_of_strings'' componentsJoinedByString:''separator'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
String.Join("-", {"a", "b", "c"}) // "a-b-c"
</source>
<source lang="python">
# Example in Python
"-".join(["a", "b", "c"]) # 'a-b-c'
</source>
<source lang="ruby">
# Example in Ruby
["a", "b", "c"].join("-") # 'a-b-c'
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-join '("a" "b" "c") "-") ; "a-b-c"
</source>
<!-- endsection -->
===lastindexof===
''see'' [[#rfind]]
===left===
{|
|- style="background:#fffeed;"
| Definition
| left(''string'',''n'') returns string
|-
| Description
| Returns the left ''n'' part of a string. If ''n'' is greater than the length of the string then most implementations return the whole string (exceptions exist - see code examples).
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string (string'First .. string'First + ''n'' - 1)
|[[Ada (programming language)|Ada]]
|-
|string:substr(''string'', ''start'', ''length'')
|[[Erlang (programming language)|Erlang]]
|-
|Left(''string'',''n'')
|[[Visual Basic|VB]]
|-
|left(''string'',''n'')
|[[Ingres (database)|Ingres]]
|-
|left(''string'',''n'' [,''padchar''])
|[[REXX (programming language)|REXX]], [[Erlang (programming language)|Erlang]]
|-
|substr(''string'', 0, ''n'')
|[[AWK]] (changes string), [[Perl]], [[PHP]]
|-
|''string''[:''n'']
|[[Python (programming language)|Python]]
|-
|''string''[0, ''n''] <br /> ''string''[0..''n'' - 1]
|[[Ruby (programming language)|Ruby]]
|-
|''string''.substr(0,''n'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|''string''[0 .. ''n'']
|[[D (programming language)|D]] (if n is largerer than length of string, then in Debug mode ArrayRangeException is thrown, in Release mode behaviour is unspecified, mostly Segmentation Fault)
|-
|''string''.Substring(0,''n'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|leftstr(''string'', ''n'')
|[[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi)
|-
|''string''.substring(0,''n'')
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|(string-take ''string'' ''n'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|take ''n'' ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' substringToIndex:''n'']
|[[Objective-C]] (<code>NSString *</code> only)
|-
|String.extract (''string'', ''n'', NONE)
|[[Standard ML]]
|-
|String.sub ''string'' 0 ''n''
|[[OCaml]] (if n is larger than length of string, raises Invalid_argument)
|-
|''string''.[..''n'']
|[[F Sharp (programming language)|F#]]
|}
<source lang="text">
/* Examples in REXX */
left("abcde", 3) /* returns "abc" */
left("abcde", 8) /* returns "abcde " */
left("abcde", 8, "*") /* returns "abcde***" */
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-take "abcde", 3) ; returns "abc"
(string-take "abcde", 8) ; error
</source>
<source lang="vb">
' Examples in Visual Basic
Left("sandroguidi", 3) ' returns "san"
Left("sandroguidi", 100) ' returns "sandroguidi"
</source>
<!-- endsection -->
===len===
''see'' [[#length]]
<!-- endsection -->
===length===
{|
|- style="background:#fffeed;"
| Definition
| length(''string'') returns an integer number
|-
| Description
| Returns the length of a string (not counting the [[null character|null terminator]] or any other of the string's internal structural information). An empty string returns a length of 0.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string'Length
|[[Ada (programming language)|Ada]]
|-
|UPB string
|[[ALGOL 68]]
|-
|length(''string'')
|[[Perl]], [[Ingres (database)|Ingres]], [[Pascal (programming language)|Pascal]], [[Object Pascal]] (Delphi), [[REXX (programming language)|REXX]]
|-
|[[Len (programming)|len]](''string'')
|[[Python (programming language)|Python]]
|-
|length(''string''), string:len(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|[[Len (programming)|Len]](''string'')
|[[Visual Basic|VB]]
|-
|''string''.Length
||[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|''string''.size OR ''string''.length
|[[Ruby (programming language)|Ruby]]
|-
|[[strlen]](''string'')
|[[C programming language|C]], [[C++]] (<code>[[character (computing)|char]] [[pointer|*]]</code> only), [[PHP]]
|-
|''string''.length()
|[[C++]] (<code>[[std::string]]</code> only), [[Java (programming language)|Java]]
|-
|''string''.length
|[[D (programming language)|D]]
|-
|''string''.length
|[[JavaScript]]
|-
|(string-length ''string'')
|[[Scheme (programming language)|Scheme]]
|-
|(length ''string'')
|[[Common Lisp]]
|-
|String.length ''string''
|[[OCaml]]
|-
|size ''string''
|[[Standard ML]]
|-
|length ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' length]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Examples in C#
"hello".Length; // returns 5
"".Length; // returns 0
</source>
<source lang="text">
# Examples in Erlang
string:len("hello"). % returns 5
string:len(""). % returns 0
</source>
<source lang="perl">
# Examples in Perl
length("hello"); # returns 5
length(""); # returns 0
</source>
<source lang="vb">
' Examples in Visual Basic
Len("hello") ' returns 5
Len("") ' returns 0
</source>
<!-- endsection -->
===locate===
''see'' [[#Find]]
<!-- endsection -->
===Lowercase===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| lowercase(''string'') returns string
|-
| Description
| Returns the string in lower case.
|-
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|LCase(''string'')
|[[Visual Basic|VB]]
|-
|lc(''string'')
|[[Perl]]
|-
|tolower(''char'')
|[[C programming language|C]] (operates on a single character)
|-
|std.string.tolower(''string'')
|[[D (programming language)|D]]
|-
|transform(''string''.begin(), ''string''.end(), ''result''.begin(), tolower)
|[[C++]] (<code>[[std::string]]</code> only, result is stored in string ''result'' which is at least as long as ''string'', and may or may not be ''string'' itself)
|-
|lowercase(''string'')
|[[Delphi programming language|Delphi]]
|-
|strtolower(''string'')
|[[PHP]]
|-
|[[echo (computing)|echo]] "string" <nowiki>|</nowiki> [[tr (program)|tr]] 'A-Z' 'a-z'
|[[Unix]]
|-
|''string''.lower()
|[[Python (programming language)|Python]]
|-
|''string''.downcase
|[[Ruby (programming language)|Ruby]]
|-
|(string-downcase ''string'')
|[[Scheme (programming language)|Scheme]] (R6RS), [[Common Lisp]]
|-
|String.lowercase ''string''
|[[OCaml]]
|-
|String.map Char.toLower ''string''
|[[Standard ML]]
|-
|map Char.toLower ''string''
|[[Haskell (programming language)|Haskell]]
|-
|''string''.toLowerCase()
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|to_lower(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|''string''.ToLower()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|[''string'' lowercaseString]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"Wiki means fast?".ToLower(); // "wiki means fast?"
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-downcase "Wiki means fast?") ; "wiki means fast?"
</source>
<source lang="vb">
' Example in Visual Basic
LCase("Wiki means fast?") ' "wiki means fast?"
</source>
<!-- endsection -->
===mid===
''see'' [[#substring]]
<!-- endsection -->
===partition===
{|
|- style="background:#fffeed;"
| Definition
| <string>.partition(''separator'') returns the sub-string before the separator; the separator; then the sub-string after the separator.
|-
| Description
| Splits the given string by the separator and returns the three substrings that together make the original.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string''.partition(''separator'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]](1.9+)
|-
|lists:partition(''pred'', ''string'')
|[[Erlang (programming language)|Erlang]]
|-
|}
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".partition('spam') # ('Spam eggs ', 'spam', ' spam and ham')
"Spam eggs spam spam and ham".partition('X') # ('Spam eggs spam spam and ham', "", "")
</source>
<!-- endsection -->
===replace===
{|
|- style="background:#fffeed;"
| Definition
| replace(''string'', ''find'', ''replace'') returns string
|-
| Description
| Returns a string the with ''find'' occurrences changed to ''replace''.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|changestr(''find'', ''string'', ''replace'')
|[[REXX (programming language)|REXX]]
|-
|std.string.replace(''string'', ''find'', ''replace'')
|[[D (programming language)|D]]
|-
|Replace(''string'', ''find'', ''replace'')
|[[Visual Basic|VB]]
|-
|''string''.Replace(''find'', ''replace'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|str_replace(''find'', ''replace'', ''string'')
|[[PHP]]
|-
|re:replace(''string'', ''find'', ''replace'', [{return, list}])
|[[Erlang (programming language)|Erlang]]
|-
|''string''.replace(''find'', ''replace'')
|[[Python (programming language)|Python]], [[Java (programming language)|Java]] (1.5+)
|-
|''string''.replaceAll(''find_regex'', ''replace'')<ref name="regex" />
|[[Java (programming language)|Java]]
|-
|''string''.gsub(''find'', ''replace'')
|[[Ruby (programming language)|Ruby]]
|-
|''string'' =~ s/''find_regex''/''replace''/g<ref name="regex">The "find" string in this construct is interpreted as a [[regular expression]]. Certain characters have special meaning in regular expressions. If you want to find a string literally, you need to quote the special characters.</ref>
|[[Perl]]
|-
|''string''.replace(''find'', ''replace'', "g") or<br /> ''string''.replace(/''find_regex''/g, ''replace'')<ref name="regex" />
|[[JavaScript]]
|-
|[[echo (computing)|echo]] "''string''" <nowiki>|</nowiki> [[sed]] 's/''find_regex''/''replace''/g'<ref name="regex" />
|[[Unix]]
|-
|''string''.replace(''find'', ''replace''), or<br />''string'' -replace ''find_regex'', ''replace''<ref name="regex" />
|[[Windows PowerShell]]
|-
|Str.global_replace (Str.regexp_string ''find'') ''replace'' ''string''
|[[OCaml]]
|-
|[''string'' stringByReplacingOccurrencesOfString:''find'' withString:''replace'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Examples in C#
"effffff".Replace("f", "jump"); // returns "ejumpjumpjumpjumpjumpjump"
"blah".Replace("z", "y"); // returns "blah"
</source>
<source lang="java5">
// Examples in Java
"effffff".replace("f", "jump"); // returns "ejumpjumpjumpjumpjumpjump"
"effffff".replaceAll("f*", "jump"); // returns "ejump"
</source>
<source lang="vb">
' Examples in Visual Basic
Replace("effffff", "f", "jump") ' returns "ejumpjumpjumpjumpjumpjump"
Replace("blah", "z", "y") ' returns "blah"
</source>
<source lang="text">
# Examples in Windows PowerShell
"effffff" -replace "f", "jump" # returns "ejumpjumpjumpjumpjumpjump"
"effffff" -replace "f*", "jump" # returns "ejump"
</source>
<!-- endsection -->
===reverse===
{|
|- style="background:#fffeed;"
| Definition
| reverse(''string'')
|-
| Description
| Reverses the order of the characters in the string.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|reverse ''string''
|[[Perl]], [[Haskell (programming language)|Haskell]]
|-
|lists:reverse(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|strrev(''string'')
|[[PHP]]
|-
|''string''[::-1]
|[[Python (programming language)|Python]]
|-
|(string-reverse ''string'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|(reverse ''string'')
|[[Common Lisp]]
|-
|''string''.reverse
|[[Ruby (programming language)|Ruby]]
|-
|new StringBuilder(''string'').reverse().toString()
|[[Java (programming language)|Java]]
|-
|std::reverse(''string''.begin(), ''string''.end());
|[[C++]] (<code>[[std::string]]</code> only, modifies string)
|-
|StrReverse(''string'')
|[[Visual Basic|VB]]
|-
|''string''.Reverse().ToString()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]]
|-
|implode (rev (explode ''string''))
|[[Standard ML]]
|}
<source lang="perl">
# Example in Perl
reverse "hello" # returns "olleh"
</source>
<source lang="python">
# Example in Python
"hello"[::-1] # returns "olleh"
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-reverse "hello") ; returns "olleh"
</source>
<!-- endsection -->
===rfind===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| rfind(''string'',''substring'') returns integer
|-
| Description
| Returns the position of the start of the last occurrence of ''substring'' in ''string''. If the ''substring'' is not found most of these routines return an invalid index value – -1 where indexes are 0-based, 0 where they are 1-based – or some value to be interpreted as Boolean FALSE.
|-
| Related
| instr
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages !! If not found
|-
|InStrRev([''startpos'', ]''string'',''substring'')
|[[Visual Basic|VB]]
|returns 0
|-
|rindex(''string'',''substring''[,''startpos''])
|[[Perl]]
|returns -1
|-
|strrpos(''string'',''substring''[,''startpos''])
|[[PHP]]
|returns FALSE
|-
|''string''.rfind(''substring''[,''startpos''])
|[[C++]] (<code>[[std::string]]</code> only)
|returns std::string::npos
|-
|std.string.rfind(''string'', ''substring'')
|[[D (programming language)|D]]
|returns -1
|-
|''string''.rfind(''substring''[,''startpos''[, ''endpos'']])
|[[Python (programming language)|Python]]
|returns -1
|-
|''string''.rindex(''substring''[,''startpos''])
|[[Ruby (programming language)|Ruby]]
|returns nil
|-
|''string''.lastIndexOf(''substring''[,''startpos''])
|[[Java (programming language)|Java]], [[JavaScript]]
|returns -1
|-
|''string''.LastIndexOf(''substring''[,''startpos''[, ''charcount'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|returns -1
|-
|(search ''substring'' ''string'' :from-end)
|[[Common Lisp]]
|returns NIL
|-
|[''string'' rangeOfString:''substring'' options:NSBackwardsSearch].___location
|[[Objective-C]] (<code>NSString *</code> only)
|returns NSNotFound
|-
|Str.search_backward (Str.regexp_string ''substring'') ''string'' (Str.length ''string'' - 1)
|[[OCaml]]
|raises Not_found
|}
<source lang="lisp">
; Examples in Common Lisp
(search "e" "Hello mate" :from-end) ; returns 9
(search "z" "word" :from-end) ; returns NIL
</source>
<source lang="csharp">
// Examples in C#
"Hello mate".LastIndexOf("e"); // returns 9
"Hello mate".LastIndexOf("e", 4); // returns 1
"word".LastIndexOf("z"); // returns -1
</source>
<source lang="vb">
' Examples in Visual Basic
InStrRev("Hello mate", "e") ' returns 10
InStrRev(5, "Hello mate", "e") ' returns 2
InStrRev("word", "z") ' returns 0
</source>
<!-- endsection -->
===right===
{|
|- style="background:#fffeed;"
| Definition
| right(''string'',''n'') returns string
|-
| Description
| Returns the right ''n'' part of a string. If ''n'' is greater than the length of the string then most implementations return the whole string (exceptions exist - see code examples).
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string (string'Last - ''n'' + 1 .. string'Last)
|[[Ada (programming language)|Ada]]
|-
|Right(''string'',''n'')
|[[Visual Basic|VB]]
|-
|right(''string'',''n'')
|[[Ingres (database)|Ingres]]
|-
|''string''.substring(''string''.length()-''n'', ''string''.length())
|[[Java (programming language)|Java]]
|-
|right(''string'',''n'' [,''padchar''])
|[[REXX (programming language)|REXX]], [[Erlang (programming language)|Erlang]]
|-
|substr(''string'',-''n'')
|[[Perl]], [[PHP]]
|-
| ''string''[-''n'':]
|[[Python (programming language)|Python]]
|-
|(string-take-right ''string'' ''n'')
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|''string''[-''n''..-1]
|[[Ruby (programming language)|Ruby]]
|-
|''string''[$-n .. $]
|[[D (programming language)|D]] (if n is larger than length of string, then in Debug mode ArrayRangeException is thrown, and unspecified behaviour in Release mode)
|-
|String.sub ''string'' (String.length ''string'' - ''n'') ''n''
|[[OCaml]] (if n is larger than length of string, raises Invalid_argument)
|}
<source lang="text">
/* Examples in REXX */
right("abcde", 3) /* returns "cde" */
right("abcde", 8) /* returns " abcde" */
right("abcde", 8, "*") /* returns "***abcde" */
</source>
<source lang="scheme">
; Examples in Scheme
(use-modules (srfi srfi-13))
(string-take-right "abcde", 3) ; returns "cde"
(string-take-right "abcde", 8) ; error
</source>
<source lang="vb">
' Examples in Visual Basic
Right("sandroguidi", 3) ' returns "idi"
Right("sandroguidi", 100) ' returns "sandroguidi"
</source>
<source lang="java">
// Examples in Java; extract rightmost 4 characters
String str = "CarDoor";
str.substring(str.length()-4, str.length()); // returns 'Door'
</source>
<!-- endsection -->
===rpartition===
{|
|- style="background:#fffeed;"
| Definition
| <string>.rpartition(''separator'') Searches for the separator from right-to-left within the string then returns the sub-string before the separator; the separator; then the sub-string after the separator.
|-
| Description
| Splits the given string by the right-most separator and returns the three substrings that together make the original.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|''string''.rpartition(''separator'')
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|}
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".rpartition('spam') ### ('Spam eggs spam ', 'spam', ' and ham')
"Spam eggs spam spam and ham".rpartition('X') ### ("", "", 'Spam eggs spam spam and ham')
</source>
<!-- endsection -->
===slice===
''see'' [[#substring]]
<!-- endsection -->
===split===
{|
|- style="background:#fffeed;"
| Definition
| <string>.split(''separator''[, ''limit'']) splits a string on separator, optionally only up to a limited number of substrings
|-
| Description
| Splits the given string by occurrences of the separator (itself a string) and returns a list (or array) of the substrings. If ''limit'' is given, after ''limit'' - 1 separators have been read, the rest of the string is made into the last substring, regardless of whether it has any separators in it. The Scheme and Erlang implementations are similar but differ in several ways. Opposite of ''join''.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|split(/''separator''/, ''string''[, ''limit''])
|[[Perl]]
|-
|explode(''separator'', ''string''[, ''limit''])
|[[PHP]]
|-
|''string''.split(''separator''[, ''limit''])
|[[Javascript]], [[Java (programming language)|Java]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]]
|-
|string:tokens(''string'', ''sepchars'')
|[[Erlang (programming language)|Erlang]]
|-
|(string-tokenize ''string''[ ''charset''[ ''start''[ ''end'']]])
|[[Scheme (programming language)|Scheme]] (SRFI 13)
|-
|Split(''string'', ''sepchars''[, ''limit''])
|[[Visual Basic|VB]]
|-
|''string''.Split(''sepchars''[, ''limit''[, ''options'']])
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]]
|-
|''string'' -split ''separator''[, ''limit''[, ''options'']]
|[[Windows PowerShell]]
|-
|Str.split (Str.regexp_string ''separator'') ''string''
|[[OCaml]]
|-
|std.string.split(''string'', ''separator'')
|[[D (programming language)|D]]
|-
|[''string'' componentsSeparatedByString:''separator'']
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"abc,defgh,ijk".Split(','); // {"abc", "defgh", "ijk"}
"abc,defgh;ijk".Split(',', ';'); // {"abc", "defgh", "ijk"}
</source>
<source lang="text">
% Example in Erlang
string:tokens("abc;defgh;ijk", ";"). % ["abc", "defgh", "ijk"]
</source>
<source lang="java">
// Examples in Java
"abc,defgh,ijk".split(','); // {"abc", "defgh", "ijk"}
"abc,defgh;ijk".split(',|;'); // {"abc", "defgh", "ijk"}
</source>
<source lang="python">
# Examples in Python
"Spam eggs spam spam and ham".split('spam') # ['Spam eggs ', ' ', ' and ham']
"Spam eggs spam spam and ham".split('X') # ['Spam eggs spam spam and ham']
</source>
<!-- endsection -->
===sprintf===
''see'' [[#Format]]
===strip===
''see'' [[#trim]]
<!-- endsection -->
===strcmp===
''see'' [[#Compare (integer result)]]
<!-- endsection -->
===substring===
{|
|- style="background:#fffeed;"
| Definition
| substring(''string'', ''startpos'', ''endpos'') returns string <br /> substr(''string'', ''startpos'', ''numChars'') returns string
|-
| Description
| Returns a substring of ''string'' between starting at ''startpos'' and ''endpos'', or starting at ''startpos'' of length ''numChars''. The resulting string is truncated if there are fewer than ''numChars'' characters beyond the starting point. ''endpos'' represents the index after the last character in the substring.
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|string[''startpos'':''endpos'']
|[[ALGOL 68]] (changes base index)
|-
|string (''startpos'' .. ''endpos'')
|[[Ada (programming language)|Ada]] (changes base index)
|-
|Mid(''string'', ''startpos'', ''numChars'')
|[[Visual Basic|VB]]
|-
|substr(''string'', ''startpos'', ''numChars'')
|[[AWK]] (changes string), [[Perl]]<sup>1,3</sup>, [[PHP]]<sup>1,3</sup>
|-
|substr(''string'', ''startpos'' [,''numChars'', ''padChar''])
|[[REXX (programming language)|REXX]]
|-
|''string''[''startpos'':''endpos'']
|[[Python (programming language)|Python]]<sup>1,2</sup>
|-
|''string''[''startpos'', ''numChars''] <br /> ''string''[''startpos'' .. ''endpos''-1] <br /> ''string''[''startpos'' ... ''endpos'']
|[[Ruby (programming language)|Ruby]]<sup>1,2</sup>
|-
|''string''.slice(''startpos'', ''endpos'')
|[[JavaScript]]
|-
|''string''.substr(''startpos'', ''numChars'')
|[[C++]] (<code>[[std::string]]</code> only)
|-
|''string''.Substring(''startpos'', ''numChars'')
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|''string''.substring(''startpos'', ''endpos'')
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|copy(''string'', ''startpos'', ''numChars'')
|[[Delphi programming language|Delphi]]
|-
|(substring ''string'' ''startpos'' ''endpos'')
|[[Scheme programming language|Scheme]]
|-
|(subseq ''string'' ''startpos'' ''endpos'')
|[[Common Lisp]]
|-
|String.sub ''string'' ''startpos'' ''numChars''
|[[Ocaml]]
|-
|substring (''string'', ''startpos'', ''numChars'')
|[[Standard ML]]
|-
|string:sub_string(''string'', ''startpos'', ''endpos'')<br />string:substr(''string'', ''startpos'', ''numChars'')
|[[Erlang programming language|Erlang]]
|-
|char ''result''[''numChars''+1] = "";<br />strncat(''result'', ''string'' + ''startpos'', ''numChars'');
|[[C programming language|C]]
|-
|''string''[''startpos .. ''endpos''+1)
|[[D (programming language)|D]]
|-
|take ''numChars'' $ drop ''startpos'' ''string''
|[[Haskell (programming language)|Haskell]]
|-
|[''string'' substringWithRange:NSMakeRange(''startpos'', ''numChars'')]
|[[Objective-C]] (<code>NSString *</code> only)
|-
|''string''.[''startpos''..''endpos'']
|[[F Sharp (programming language)|F#]]
|}
# In this language, ''startpos'' can be negative, which indicates to start that number of places before the end of the string.
# In this language, ''endpos'' can be negative, which indicates to end that number of places before the end of the string.
# In this language, ''numChars'' can be negative, which indicates to end that number of places before the end of the string.
<source lang="csharp">
// Examples in C#
"abc".Substring(1, 1): // returns "b"
"abc".Substring(1, 2); // returns "bc"
"abc".Substring(1, 6); // error
</source>
<source lang="text">
% Examples in Erlang
string:substr("abc", 2, 1). % returns "b"
string:substr("abc", 2). % returns "bc"
</source>
<source lang="python">
# Examples in Python
"abc"[1:1] # returns "b"
"abc"[1:2] # returns "bc"
</source>
<source lang="text">
/* Examples in REXX */
substr("abc", 2, 1) /* returns "b" */
substr("abc", 2) /* returns "bc" */
substr("abc", 2, 6) /* returns "bc " */
substr("abc", 2, 6, "*") /* returns "bc****" */
</source>
<!-- endsection -->
===Uppercase===
<!-- startsection -->
{|
|- style="background:#fffeed;"
| Definition
| uppercase(''string'') returns string
|-
| Description
| Returns the string in upper case.
|-
|}
{| class="wikitable sortable"
|- align="left"
! Format !! Languages
|-
|UCase(''string'')
|[[Visual Basic|VB]]
|-
|toupper(''string'')
|[[AWK]] (changes string)
|-
|uc(''string'')
|[[Perl]]
|-
|toupper(''char'')
|[[C programming language|C]] (operates on a single character)
|-
|std.string.toupper(''string'')
|[[D (programming language)|D]]
|-
|transform(''string''.begin(), ''string''.end(), ''result''.begin(), toupper)
|[[C++]] (<code>[[std::string]]</code> only, result is stored in string ''result'' which is at least as long as ''string'', and may or may not be ''string'' itself)
|-
|uppercase(''string'')
|[[Delphi programming language|Delphi]]
|-
|strtoupper(''string'')
|[[PHP]]
|-
|[[echo (computing)|echo]] "string" <nowiki>|</nowiki> [[tr (program)|tr]] 'a-z' 'A-Z'
|[[Unix]]
|-
|translate(''string'')
|[[REXX (programming language)|REXX]]
|-
|''string''.upper()
|[[Python (programming language)|Python]]
|-
|''string''.upcase
|[[Ruby (programming language)|Ruby]]
|-
|(string-upcase ''string'')
|[[Scheme (programming language)|Scheme]], [[Common Lisp]]
|-
|String.uppercase ''string''
|[[OCaml]]
|-
|String.map Char.toUpper ''string''
|[[Standard ML]]
|-
|map Char.toUpper ''string''
|[[Haskell (programming language)|Haskell]]
|-
|''string''.toUpperCase()
|[[Java (programming language)|Java]], [[JavaScript]]
|-
|to_upper(''string'')
|[[Erlang (programming language)|Erlang]]
|-
|''string''.ToUpper()
|[[Visual Basic .NET|VB .NET]], [[C Sharp (programming language)|C#]], [[Windows PowerShell]], [[F Sharp (programming language)|F#]]
|-
|[''string'' uppercaseString]
|[[Objective-C]] (<code>NSString *</code> only)
|}
<source lang="csharp">
// Example in C#
"Wiki means fast?".ToUpper(); // "WIKI MEANS FAST?"
</source>
<source lang="text">
/* Example in REXX */
translate("Wiki means fast?") /* "WIKI MEANS FAST?" */
</source>
<source lang="scheme">
; Example in Scheme
(use-modules (srfi srfi-13))
(string-upcase "Wiki means fast?") ; "WIKI MEANS FAST?"
</source>
<source lang="vb">
' Example in Visual Basic
UCase("Wiki means fast?") ' "WIKI MEANS FAST?"
</source>
<!-- endsection -->
===trim===
{{main|Trim (programming)}}
'''trim''' or '''strip''' is used to remove whitespace from the beginning, end, or both beginning and end, of a string.
== Notes ==
{{reflist}}
== External links ==
*[http://perldoc.perl.org/index-functions-by-cat.html#Functions-for-SCALARs-or-strings Perl String Functions]
*[http://docs.python.org/lib/string-methods.html Python String Methods]
*[http://srfi.schemers.org/srfi-13/srfi-13.html Scheme String Procedures]
*[http://www.erlang.org//doc/man/string.html Erlang String Functions]
*[http://www.and.org/ustr/ The Ustr String Library]
*[http://msdn2.microsoft.com/en-us/library/system.string_members.aspx .NET String Methods and Properties]
*[http://www.ruby-doc.org/core-1.8.7/classes/String.html Ruby String Class]
*[http://www.php.net/manual/en/ref.strings.php PHP String functions]
*{{javadoc:SE|java/lang|String|package=java.lang}} members
*[http://www.string-functions.com/ Online String Manipulation Tools]
*[http://haskell.org/ghc/docs/latest/html/libraries/ Haskell Hierarchical Libraries]
*[http://www.digitalmars.com/d/2.0/phobos/std_string.html std.string from Phobos (D standard library)]
*[http://academicearth.org/lectures/string-processing Stanford Computer Science lecture on string processing]
[[Category:Programming language comparisons]]
[[Category:Articles with example Python code]]
[[es:Sustitución (informática teórica)]]' |
Whether or not the change was made through a Tor exit node (tor_exit_node ) | 0 |
Unix timestamp of change (timestamp ) | 1248627805 |