From: Warren Brown Date: 2003-04-17T00:05:40+09:00 Subject: Re: case insensitive match with regexp object Gavin, > So you can do > > def insensitive(regex) > Regexp.new(regex, Regexp::IGNORE_CASE) > end > > However, ri tells me that when a regex is given to > Regexp.new, *its options are not propagated* !! > > Therefore, the definition of #insensitive above is > incorrect for inputs that have Regexp::EXTENDED or > Regexp::POSIX_LINE enabled, and I can't see any way > to define it correctly. It looks like this oversight has been fixed in 1.8: %ruby -v -e "x = /x/imx; puts x.options" ruby 1.8.0 (2003-04-04) [i386-freebsd4.7] 135 So your function could be: def insensitive(regex) Regexp.new(regex, regex.options | Regexp::IGNORECASE) end Or even: def insensitive(regex) if regex.options & Regexp::IGNORECASE regex else Regexp.new(regex, regex.options | Regexp::IGNORECASE) end end - Warren Brown