Table of Contents
Home / Definitions / Raw String
Languages 2 min read

A raw string in programming allows all characters in a string literal to remain the same in code and in the material, rather than performing their standard programming functions. Raw strings are denoted with the letter r, or capital R, and might look something like this:

R “(hello)”

This allows characters that would otherwise trigger specific formatting to read as their literal value instead. A backslash () is a good example: these are often combined with other characters to denote a specific action in programming. Different programming languages have different patterns for raw strings, and they may have different delimiters, but most raw strings take the same general form.

Delimiters in raw strings

Raw strings avoid using escape sequences, which automatically trigger a different feature within the code (such as a paragraph break or other function). In the earlier example of a raw string: 

R “(hello)”

the parentheses or quotations can both function as delimiters, which segment string literals properly. Delimiters designate a string literal. Characters or strings that need to be separated are often parenthetical or bracketed. Different programming languages will use different delimiters, but they must delineate the separation of strings clearly. In this case, R indicates a raw string, and everything within the parentheses will read as its literal character value.

Was this Article helpful? Yes No
Thank you for your feedback. 0% 0%