source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/eregex.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 487 bytes
Line 
1# this is just a proof of concept toy.
2
3class RegOr
4 def initialize(re1, re2)
5 @re1 = re1
6 @re2 = re2
7 end
8
9 def =~ (str)
10 @re1 =~ str or @re2 =~ str
11 end
12end
13
14class RegAnd
15 def initialize(re1, re2)
16 @re1 = re1
17 @re2 = re2
18 end
19
20 def =~ (str)
21 @re1 =~ str and @re2 =~ str
22 end
23end
24
25class Regexp
26 def |(other)
27 RegOr.new(self, other)
28 end
29 def &(other)
30 RegAnd.new(self, other)
31 end
32end
33
34if __FILE__ == $0
35 p "abc" =~ /b/|/c/
36 p "abc" =~ /b/&/c/
37end
Note: See TracBrowser for help on using the repository browser.