Created
February 26, 2010 00:28
-
-
Save kronos/315236 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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