Table of Contents
    Home / Definitions / String Literal
    Development 2 min read

    A string literal is a programming string in which characters exist as their literal value rather than a variable and appear the same in code and in published material. They are denoted by delimiters. Delimiters are characters, often quotation marks or brackets, that contain a string literal. In the following example, the quotation marks are delimiters:

    ” Hello World! “

    Programmers can concatenate string literals, typically by placing them directly next to each other:

    “Hello” “World”



    In string literals, escape sequences are used to denote characters or functions that are challenging to represent in plain code or that might otherwise cause an error. Escape sequences are often initiated using a backslash (). If a programmer wishes to represent every single character in a string literal exactly as it is meant to be read, including backslashes or other character combinations that typically represent an escape sequence, they can create a raw string instead.

    Raw string vs. string literal

    A raw string is a special kind of string literal in which even escape sequences read directly as code rather than performing their usual function.

    The character R designates a raw string:

    R “(hello)”

    in which the quotations or the parentheses can function as delimiters.