Skip to content

Commit

Permalink
RRE2 wrapper wraps functions inside the String class
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Mar 17, 2010
1 parent 85fd435 commit 0b40f80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rre2-wrapper.rb
@@ -0,0 +1,13 @@
require 'rre2'

class String
def match(pattern)
RRE2.new(pattern).match(self.to_s)
end

def gsub(pattern, replacement)
RRE2.gsub(self.to_s, pattern, replacement)
end

# to be implemented: gsub!, scan
end
5 changes: 5 additions & 0 deletions test3.rb
@@ -0,0 +1,5 @@
require 'rre2-wrapper'

puts "This will be replaced".gsub("will\s+be", "was")

puts "Simple text to run match on".match("text")

0 comments on commit 0b40f80

Please sign in to comment.