At Wed, 25 Sep 2002 06:57:01 +0900,
Joel VanderWerf wrote:

> irb(main):001:0> /ab/+"cd"
> NameError: undefined method `+' for /ab/:Regexp
>          from (irb):1
> irb(main):002:0> class Regexp
> irb(main):003:1>   def +(str)
> irb(main):004:2>     Regexp.new(source + str)
> irb(main):005:2>   end
> irb(main):006:1> end
> nil
> irb(main):007:0> /ab/+"cd"
> /abcd/
> 
> Seems reasonable. But then you would also want to test for a regex 
> argument (and you can't just apply #to_s), and possibly other arguments.
> 
> Is there a reason this doesn't already exist?

I don't know the reasons but I can imagine

  * Other #+ hardly raise but Regexp#+ does easily: /ab/ + "|"

  * source+Regexp::escape(str) is sefe but too rigid

  * Options wounld not be preserved: /<.*/m + ">" != /<.*>/m

  * Ruby 1.7 has Regexp#options but what is reasonable //mu + //nx

  * What should happen: "" + //


-- Gotoken