A
string literal or
anonymous string is the representation of a
string value within the
source code of a
computer program. Most often in modern languages this is a quoted sequence of characters (formally "bracketed delimiters"), as in
x = "foo"
, where
"foo"
is a string
literal with value
foo
– the quotes are not part of the value, and one must use a method such as escape characters to avoid the problem of delimiter collision and allow the delimiters themselves to be embedded in a string. However, there are numerous alternate notations for specifying string literals, particularly more complicated cases, and the exact notation depends on the individual
programming language in question. Nevertheless, there are some general guidelines that most modern programming languages follow.