Invented by Bob Bemer, an escape sequence is two or more characters that often begin with an escape character that tell the computer to perform a function or command. Below is a listing of some commonly used escape sequences used in programming languages and text editors.

Below is an example of how an escape sequence appears to a computer and to the user.

Hello.\nHere is an example of text that uses\nescape sequences.

The above example with escape sequences would display the below text.

Hello. Here is an example of text that uses escape sequences.

Finally, adding an escape sequence into a regex (regular expression) can allow you to find and replace characters or perform a special feature. For example, in the example below of a Perl regular expression in a while loop we’re deleting any line beginning with a return.

while () { $line = $_; $line =~ s/^\n//g; }

Control character, Escape, Escape character, Printf, Programming terms, Regex, Reserved character

  • Extended special HTML characters and codes.
  • How to create a computer program.