From: Jeff Wood Date: 2005-11-27T10:00:14+09:00 Subject: Re: String#to_rx ? Although I am surprised there isn't a String#escape ( or maybe #escaped ) method /#{ b.escaped }/ ... or something like that. would be literal, and make sense ... j. On 11/26/05, Jeff Wood wrote: > I didn't want them to be ... I wanted the body of the string to be > passed in literally ... > > Yes, I understand if I wanted otherwise I would have to do just a > touch more work... > > c = /#{ Regexp.escape( b ) }/ > > but, it's all literal, and doesn't surprise me... as it shouldn't anyone else. > > /#{ b }/ where b = "w.*" should be /w.*/ > > ... guess I'm not understanding the original point ... somebody > wanting an additional wrapper for strings that auto escapes them ? > > why not write one %e( ) or something like that. > > ... > > j. > > > On 11/26/05, Trans wrote: > > Jeff, > > > > a = "hello world" > > b = "w.*" > > c = /#{ b }/ > > c.match( a ).to_a > > #=> ["world"] > > > > Characters arn't escaped. > > > > T. > > > > > > > > > -- > "Remember. Understand. Believe. Yield! -> http://ruby-lang.org" > > Jeff Wood > > -- "Remember. Understand. Believe. Yield! -> http://ruby-lang.org" Jeff Wood