Module: Arrow::RegexpOperators

Included in:
Regexp
Defined in:
lib/arrow/monkeypatches.rb

Overview

Add some operator methods to regular expression objects for catenation, union, etc.

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object

Append the given other Regexp (or String) onto a copy of the receiving one and return it.



23
24
25
# File 'lib/arrow/monkeypatches.rb', line 23

def +( other ) 
	return self.class.new( self.to_s + other.to_s )
end

#|(other) ⇒ Object

Create and return a new Regexp that is an alternation between the receiver and the other Regexp.



29
30
31
# File 'lib/arrow/monkeypatches.rb', line 29

def |( other )
	return Regexp.new( "(?:%s|%s)" % [self.to_s, other.to_s] )
end