From: nobu.nokada@... Date: 2003-06-01T01:35:15+09:00 Subject: Re: regexp operators Hi, At Sun, 1 Jun 2003 00:10:15 +0900, Wesley J Landaker wrote: > Well, + meaning concatination makes sense to me. What else would it > mean? Notice that I do put regexps in (?:) groups so that you don't > have any ambiguity if you do something like: > > /foo|bar/ + /.*/ # => /(?:foo|bar)(?:.*)/u One possibility: => /(?:foo|bar).*(?:.*)/u > One thing that's missing from the packages you point at is that the > object you get back isn't completely usable as a regexp. They could be > extended to have the missing methods, of course, but they don't > currently support them. And if you've added or modified any methods in > regexp, these objects are of a different type (and aren't class > descendants) so won't have the changes applied to them (say, if I > redefine to_s or source or something like that) Yes, I know it's a problem. Not only you mentioned, some methods of String expect Regexp instance. > BTW, I never wrote '&' because I didn't really need it, but it could be > done with something like this: > > In RegexpOps.rb: > # the other code I posted goes here > class Regexp > def &(other) > /(?=#{self})#{other}/u > end > end Seems nice. > Of course, that regexp will never match anything, but you get the idea. > ;) Maybe, /(?=.*(?:foo)).*(?:bar)/? -- Nobu Nakada