ruby-changes:48211
From: sonots <ko1@a...>
Date: Sun, 22 Oct 2017 08:38:21 +0900 (JST)
Subject: [ruby-changes:48211] sonots:r60326 (trunk): * doc/regexp.rdoc: In regexp doc, two backslashes match one literally
sonots 2017-10-22 08:38:17 +0900 (Sun, 22 Oct 2017) New Revision: 60326 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60326 Log: * doc/regexp.rdoc: In regexp doc, two backslashes match one literally In the "Metacharacters and Escapes" section of regexp.rdoc, it said that to match a backslash literally, it must be backslash-escaped, but the rendered HTML showed three backslashes (\\\). There should only be two backslashes (\\). patched by jlmuir (J. Lewis Muir) [fix GH-1677] Modified files: trunk/doc/regexp.rdoc Index: doc/regexp.rdoc =================================================================== --- doc/regexp.rdoc (revision 60325) +++ doc/regexp.rdoc (revision 60326) @@ -63,9 +63,10 @@ The following are <i>metacharacters</i> https://github.com/ruby/ruby/blob/trunk/doc/regexp.rdoc#L63 <tt>[</tt>, <tt>]</tt>, <tt>{</tt>, <tt>}</tt>, <tt>.</tt>, <tt>?</tt>, <tt>+</tt>, <tt>*</tt>. They have a specific meaning when appearing in a pattern. To match them literally they must be backslash-escaped. To match -a backslash literally backslash-escape that: <tt>\\\\\\</tt>. +a backslash literally, backslash-escape it: <tt>\\\\</tt>. /1 \+ 2 = 3\?/.match('Does 1 + 2 = 3?') #=> #<MatchData "1 + 2 = 3?"> + /a\\\\b/.match('a\\\\b') #=> #<MatchData "a\\b"> Patterns behave like double-quoted strings so can contain the same backslash escapes. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/