所有的转义字符是什么?

我知道一些 Java 中的转义字符,例如。

\n : Newline
\r : Carriage return
\t : Tab
\\ : Backslash
...

有完整的清单吗?

576350 次浏览

您可以找到完整的列表 给你

  • 此时在文本中插入一个选项卡。
  • 此时在文本中插入一个退格。
  • 此时在文本中插入换行符。
  • 此时在文本中插入回车符。
  • 此时在文本中插入一个 formfeed。
  • 此时在文本中插入一个空格。
  • 此时在文本中插入单引号字符。
  • 此时在文本中插入双引号字符。
  • 此时在文本中插入反斜杠字符。
Java Escape Sequences:


\u{0000-FFFF}  /* Unicode [Basic Multilingual Plane only, see below] hex value
does not handle unicode values higher than 0xFFFF (65535),
the high surrogate has to be separate: \uD852\uDF62
Four hex characters only (no variable width) */
\b             /* \u0008: backspace (BS) */
\t             /* \u0009: horizontal tab (HT) */
\n             /* \u000a: linefeed (LF) */
\f             /* \u000c: form feed (FF) */
\r             /* \u000d: carriage return (CR) */
\"             /* \u0022: double quote (") */
\'             /* \u0027: single quote (') */
\\             /* \u005c: backslash (\) */
\{0-377}       /* \u0000 to \u00ff: from octal value
1 to 3 octal digits (variable width) */

基本多语言平面是来自0x0000-0xFFFF (0-65535)的 unicode 值。在 Java 中,额外的平面只能通过多个字符来指定: 埃及象形文字 A054(躺下的哥们)是 U+1303F/𓀿,对于 Java 字符串,必须分成 "\uD80C\uDC3F"(UTF-16)。其他一些语言使用 "\U0001303F"支持更高的平面。

是的,下面是 doc.Oracle 的链接,你可以在这里找到 Java 中转义字符的完整列表。

转义字符总是 前面加了“”,用于执行一些特定的任务,如转到下一行等。

有关转义字符的详细资料,请参阅以下连结:

Https://docs.oracle.com/javase/tutorial/java/data/characters.html

这些是用于操作字符串的转义字符。

\t  Insert a tab in the text at this point.
\b  Insert a backspace in the text at this point.
\n  Insert a newline in the text at this point.
\r  Insert a carriage return in the text at this point.
\f  Insert a form feed in the text at this point.
\'  Insert a single quote character in the text at this point.
\"  Insert a double quote character in the text at this point.
\\  Insert a backslash character in the text at this point.

从这里了解更多关于他们的信息。

Http://docs.oracle.com/javase/tutorial/java/data/characters.html

另外,旧版本的 Java 支持 \v作为表单提要。

来自: java/util/regex/Pattern.java:

2600         case 'v':
2601             // '\v' was implemented as VT/0x0B in releases < 1.8 (though
2602             // undocumented). In JDK8 '\v' is specified as a predefined
2603             // character class for all vertical whitespace characters.
2604             // So [-1, root=VertWS node] pair is returned (instead of a
2605             // single 0x0B). This breaks the range if '\v' is used as
2606             // the start or end value, such as [\v-...] or [...-\v], in
2607             // which a single definite value (0x0B) is expected. For
2608             // compatibility concern '\013'/0x0B is returned if