我在哪里可以找到Ruby文档中的字符串转义序列?

his*_*eim 7 ruby

我可以在" Ruby Strings "和" Escape sequences "中找到Ruby的转义序列的详细信息.但是,在官方Ruby文档中我可以找到有关字符串转义序列的详细信息吗?

这个问题对于刚刚学习Ruby的人来说很重要,因为了解如何简单地浏览文档是一个初步的挑战.

小智 11

请参阅已更新的官方文档,其中包含受支持的转义字符的完整列表:

\0             null, ASCII 00h (NUL)
\a             bell, ASCII 07h (BEL)
\b             backspace, ASCII 08h (BS)
\t             horizontal tab, ASCII 09h (TAB)
\n             newline (line feed), ASCII 0Ah (LF)
\v             vertical tab, ASCII 0Bh (VT)
\f             form feed, ASCII 0Ch (FF)
\r             carriage return, ASCII 0Dh (CR)
\e             escape, ASCII 1Bh (ESC)
\s             space, ASCII 20h (SPC)
\\             backslash, \
\nnn           octal bit pattern, where nnn is 1-3 octal digits ([0-7])
\xnn           hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
\unnnn         Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
\u{nnnn ...}   Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
\cx or \C-x    control character, where x is an ASCII printable character
\M-x           meta character, where x is an ASCII printable character
\M-\C-x        meta control character, where x is an ASCII printable character
Run Code Online (Sandbox Code Playgroud)

如果您发现任何要添加或修复的内容,我们欢迎通过GitHub上的pull-request或我们的问题跟踪器提供反馈和贡献.


Pet*_*vin 3

虽然对于“官方”文档的构成有不同的看法,但我会提供http://www.ruby-doc.org/core-2.0.0/doc/syntax/literals_rdoc.html#label-Strings作为您的答案问题。

  • 由于链接页面未提供转义序列列表而被否决 (2认同)