Patches: Browse | Submit New | Admin

[#5297] More detailed RDoc for String#sub, gsub (\\, \&,...)

Date:
2006-08-04 07:47
Priority:
3
Submitted By:
Jano Svitok (janek)
Assigned To:
Eric Hodel (drbrain)
Category:
Documentation, ri, and rdoc
State:
Open
Summary:
More detailed RDoc for String#sub, gsub (\\, \&,...)

Detailed description
From the thread:  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/8344

> On 7/21/06, ts <decoux / moulon.inra.fr> wrote:
> >  "\\'" is the same than $', i.e. MatchData#post_match. For example
> 
> Now that makes more sense... I didn't know that. After looking in the
> documentation, I found this only in PickAxe book. I haven't found it
> neither in the 1.8 RDoc nor in the mentioned article.
> 
> Attached is a patch against 1.182.2.48 revision of string.c, that adds
> these sequences to rdoc (shamelessly ripped from the pickaxe book).

--- string.c.orig	Fri Jul 21 20:43:50 2006
+++ string.c	Fri Jul 21 20:51:17 2006
@@ -2015,9 +2015,14 @@
  *     
  *  If the method call specifies <i>replacement</i>, special variables such as
  *  <code>$&</code> will not be useful, as substitution into the string occurs
- *  before the pattern match starts. However, the sequences <code>\1</code>,
- *  <code>\2</code>, etc., may be used.
- *     
+ *  before the pattern match starts. However, the following sequences may be used:
+ *  
+ *     \1,\2,...\9      The value matched by the <i>nth</i> grouped subexpression
+ *     \&               The last match
+ *     \`               The part of the string before the match
+ *     \'               The part of the string after the match
+ *     \+               The highest-numbered group matched
+ *  
  *  In the block form, the current match string is passed in as a parameter, and
  *  variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
  *  <code>$&</code>, and <code>$'</code> will be set appropriately. The value
@@ -2204,7 +2209,7 @@
  *  (such as <code>$&</code> and <code>$1</code>) cannot be substituted into it,
  *  as substitution into the string occurs before the pattern match
  *  starts. However, the sequences <code>\1</code>, <code>\2</code>, and so on
- *  may be used to interpolate successive groups in the match.
+ *  (see <code>String::sub</code>) may be used to interpolate successive groups in the match.
  *     
  *  In the block form, the current match string is passed in as a parameter, and
  *  variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
string-sub-rdoc.patch Download

Changes:

Field Old Value Date By
assigned_tonone2007-06-13 06:28zenspider
summaryMore detailed RDoc for String#sub, gsub (\\, \&amp;amp;,...)2007-06-13 06:28zenspider
category_idMisc / Other Standard Library2007-05-30 04:06zenspider
summaryMore detailed RDoc for String#sub, gsub (\\, \&amp;,...)2007-05-30 04:06zenspider
category_idNone2007-05-30 03:50zenspider
summaryMore detailed RDoc for String#sub, gsub (\\, \&,...)2007-05-30 03:50zenspider
File Added728: string-sub-rdoc.patch2006-08-04 07:47janek