String functions are used in computer programming languages to manipulate a string or query information about a string (some do both). Most 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. For function that manipulate strings, modern object-oriented languages, like C# and Java have immutable strings and return a copy (in newly allocated dynamic memory), while others, like C manipulate the original string unless the programmer copies data to a new string. See for example Concatenation below. The most basic example of a string function is the length(string) function. This function returns the length of a string literal. e.g. 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(string). The below list of common functions aims to help limit this confusion. Common string functions (multi language reference) String functions common to many languages are listed below, including the different names used. 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. Statements in guillemets (« … ») are optional. CharAt { Example in Pascal } var MyStr: string = 'Hello, World'; MyChar: Char; begin MyChar := MyStr[2]; // 'e' # Example in ALGOL 68 # "Hello, World"[2]; // 'e' // Example in C #include <stdio.h> // for printf char MyStr[] = "Hello, World"; printf("%c", *(MyStr+1)); // 'e' printf("%c", *(MyStr+7)); // 'W' printf("%c", MyStr[11]); // 'd' printf("%s", MyStr); // 'Hello, World' printf("%s", "Hello(2), World(2)"); // 'Hello(2), World(2)' // Example in C++ #include <iostream> // for "cout" #include <string.h> // for "string" data type using namespace std; char MyStr1[] = "Hello(1), World(1)"; string MyStr2 = "Hello(2), World(2)"; cout << "Hello(3), World(3)"; // 'Hello(3), World(3)' cout << MyStr2[6]; // '2' cout << MyStr1.substr (5, 3); // '(1)' // Example in C# "Hello, World"[2]; // 'l' # Example in Perl 5 substr("Hello,