Dave Braunschweig

Overview

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

Discussion

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 Terms

concatenate
Join character strings end-to-end.[2]
trim
Remove leading and trailing spaces from a string.[3]

References


License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Programming Fundamentals Copyright © 2018 by Dave Braunschweig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book