What is a Character String?
A character string or a string in computer science is a sequence of characters from a defined character set. Characters can be repeated in a character string, the order of the characters is defined. Character strings are thus sequences of symbols with finite length.
In programming, a character string is a data type that contains a string of characters of fixed or variable length. This mainly stores words, sentences and entire texts. Almost every programming language has such a data type and some programming languages only work with this data type. Examples are sed, awk, and bash.
In the source text of a computer program, character strings represent text that is not interpreted as a programming command but contains information. For example, error messages or other outputs to the user can be recorded as a character string in the source text, or user inputs can be saved as character strings in variables. The basics of programming languages are examined in theoretical computer science.
the text of a string is enclosed between double or single quotation marks. You can think of strings like a list, the elements of which are individual characters. Most of the operations you are familiar with for lists can therefore also be used for strings, with one important difference: You can extract a single character from the string with an index but you cannot change the character with an assignment, since the string is an immutable data type. If you want to change a string, you will have to create a new string.
A string can also contain special control characters. This escape character is a backward Bruchstrich initiated (backslash), for example, is the sign of a new line \ n (newline, also called Line Feed <lf>).