From: Wesley J Landaker Date: 2003-05-31T08:59:45+09:00 Subject: Re: regexp operators On Friday 30 May 2003 5:41 pm, nobu.nokada@softhome.net wrote: > Hi, > > At Sat, 31 May 2003 03:26:53 +0900, > > Wesley J Landaker wrote: > > So I whipped this out really quick. It lets you combine regexp by > > adding them (+), ORing them (|) or by including them > > /blah#{some_regexp}blah/ inside each other, while preserving all > > flags. (At least, all flags that can be preserved--I can't do > > anything about the encodings if they mismatch... but I use all > > UTF-8 regexps, so I always use 'u'). This could potentially be > > extended to support other operations--but I haven't needed them yet > > on the project I'm tinkering with. > > Flags are preserved in 1.8. > > $ ruby -v -e 'p(/#{/foo/m}/)' > ruby 1.8.0 (2003-05-31) [i686-linux] > /(?m-ix:foo)/ I hadn't tried this in 1.8 yet, so that's cool to see that it has built in a to_s similar to the one I posted. Nice! =) Mine also does the + and | operators, as well, though; I'm not sure if that's universally useful. Looks like 1.8 still doesn't catch encoding flag in this case; there doesn't appear to be any '(?' prefix that changes encodings, though, which would be a prerequisite. (Personally, I'm happy with UTF-8. ;) $ ruby -v -e 'p(/#{/foo/mu}/)' ruby 1.8.0 (2003-05-31) [i686-linux] /(?m-ix:foo)/ -- Wesley J. Landaker - wjl@icecavern.net OpenPGP FP: C99E DF40 54F6 B625 FD48 B509 A3DE 8D79 541F F830