Escape character is a character that signals the start of an escape sequence. The purpose of an escape sequence is to signal the interpreter that the following characters should be treated differently. For example, in C programming language strings, the backslash \ is used as an escape character. This means that if you want to include a backslash as a character in your string, you must use \\.
In other programming languages, different characters may be used as escape characters. In some cases, there may be more than one escape character. For example, in Java, both the backslash \ and double quote ” can be used as escape characters.
There are also a few other uses for escape characters. In some cases, an escape character is used to indicate that the following character should be treated as a literal. For example, in regular expressions, the backslash \ is often used to escape special characters that would otherwise have a special meaning.
Examples of Escape Character
The following are some examples of escape characters:
- \t – Tab
- \n – New line
- \\ – Backslash
- \’ – Single quote
- \” – Double quote
- \r – Carriage return
- \b – Backspace
- \f – Form feed