Programming Fundamentals/String Functions


String functions are used in computer programming languages to manipulate a string or query information about a string.[1]


Most current programming languages include built-in or library functions to process strings. Common examples include case conversion, comparison, concatenation, find, join, length, reverse, split, substring, and trim.

Function C++ C# Java
case tolower(), toupper(), etc. ToLower(), ToUpper(), etc. toLowerCase(), toUpperCase(), etc.
comparison <, >, ==, etc. <, >, ==, etc. <, >, ==, etc.
concatenation +, += +, += +, +=
find find() IndexOf() indexOf()
join N/A Join() join()
length length() Length length()
replace replace() Replace() replace()
reverse reverse() Reverse() N/A
split strtok() Split() split()
substring substr() Substring() substring()
trim N/A Trim() trim()
Function JavaScript Python Swift
case toLowerCase(), toUpperCase(), etc. lower(), upper(), etc. lowercased(), uppercased()
comparison <, >, ==, etc. <, >, ==, etc. <, >, ==, etc.
concatenation +, += +, += +, +=
find indexOf() find() firstIndex()
join join() join() joined()
length length len() count
replace replace() replace() replacingOccurrences()
reverse N/A string[::-1] reversed()
split split() split() split()
substring substring() string[start:end] string[start...end]
trim trim() strip() trimmingCharacters()

Key TermsEdit

A function that either makes a string all uppercase or lowercase depending on which mode is used.
Determines if the value (string or non-string), is less than, greater than, or equal to the value it's being compared to.
Join character strings end-to-end.[2]
Checks if a character in a string exists and if it does, finds the location of that character in the string.
Joins strings together using a character of the person's choosing.
Finds how many characters are in a string, or the number of elements in an array.
Replaces all instances of one character in a string with another.
Places all characters of a string or elements in an array in reverse order.
Divides a string's content onto separate lines based off a chosen character.
Creates a smaller string by using characters from a bigger string.[3]
Remove leading and trailing spaces from a string.[4]