String Literal

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”

equals

“HelloWorld”

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.






Jenna Phipps
Jenna Phipps is a contributor for websites such as Webopedia.com and Enterprise Storage Forum. She writes about information technology security, networking, and data storage. Jenna lives in Nashville, TN.

Top Articles

The Complete List of 1500+ Common Text Abbreviations & Acronyms

Text Abbreviations reviewed by Web Webster   From A3 to ZZZ we list 1,559 SMS, online chat, and text abbreviations to help you translate and understand...

Windows Operating System History & Versions

The Windows operating system (Windows OS) refers to a family of operating systems developed by Microsoft Corporation. We look at the history of Windows...

How to Create a Website Shortcut on Your Desktop

Website Shortcut on Your Desktop reviewed by Web Webster   This Webopedia guide will show you how to create a website shortcut on your desktop using...

Generations of Computers (1st to 5th)

Reviewed by Web Webster Learn about each of the 5 generations of computers and major technology developments that have led to the computing devices that...

Telecommunication

Telecommunication refers to telephony and cellular network technology. However, the broader definition includes...

Spoofing

What is spoofing? As it pertains to cybersecurity, spoofing is when a person disguises...

How to Indent in...

Microsoft Word is a graphical word...