Skip to content

Instantly share code, notes, and snippets.

@psi
Created May 14, 2010 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psi/401439 to your computer and use it in GitHub Desktop.
Save psi/401439 to your computer and use it in GitHub Desktop.
From 551f672638e05221ad898fdbd3c1ea8ef56aa627 Mon Sep 17 00:00:00 2001
From: JD Harrington <psi@y0ru.net>
Date: Fri, 14 May 2010 12:13:13 -0400
Subject: [PATCH] Fix Regexp#to_s when using %r
---
kernel/common/regexp.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/common/regexp.rb b/kernel/common/regexp.rb
index d15f8b7..9d46c7d 100644
--- a/kernel/common/regexp.rb
+++ b/kernel/common/regexp.rb
@@ -293,7 +293,7 @@ class Regexp
end
def to_s
- source
+ source.gsub(%r!(^|[^\\])/!) { "#{$1}\\/" }
end
def has_options!
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment