Skip to content

Instantly share code, notes, and snippets.

@kronos
Created February 26, 2010 00:28
Show Gist options
  • Save kronos/315236 to your computer and use it in GitHub Desktop.
Save kronos/315236 to your computer and use it in GitHub Desktop.
diff --git a/kernel/common/regexp.rb b/kernel/common/regexp.rb
index a779e4f..15a12b0 100644
--- a/kernel/common/regexp.rb
+++ b/kernel/common/regexp.rb
@@ -639,7 +639,14 @@ class MatchData
end
def inspect
- "#<MatchData:0x#{object_id.to_s(16)} \"#{matched_area}\">"
+ capts = captures
+ unless capts.empty?
+ idx = 0
+ capts.map! {|capture| "#{idx += 1}:#{capture.inspect}"}
+ "#<MatchData \"#{matched_area}\" #{capts.join(" ")}>"
+ else
+ "#<MatchData \"#{matched_area}\">"
+ end
end
def select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment