Boson
4/10/2008 2:00:00 PM
Chris Shea wrote:
> I don't know how much better this is, but you could union first, then
> add the case-insensitivity:
>
> fruits = ["apples","oranges","grapes"]
> r = Regexp.union(*fruits)
> r = Regexp.new(r.source, Regexp::IGNORECASE) # => /apples|oranges|
> grapes/i
This solution works. Thanks.
Looking at the Ruby source, it wouldn't be hard to add an options
parameter to Regexp.union to avoid such re-conversions.