From: Ken Bloom Date: 2007-06-12T10:10:08+09:00 Subject: Re: why gsub! doesn't work in my script On Tue, 12 Jun 2007 02:49:10 +0900, Li Chen wrote: > 1) what is the best scenario to use Regexp.escape? You use Regexp.escape when you're building up a regular expression programmatically as a String, and using Regexp.new to turn it into a regular expression. In that case, all of the control codes in the string will be interpreted, so if you have a string that needs to be matched literally, then you use Regexp.escape to escape it first. This is also the case when using variable interpolation. airb(main):001:0> a="..." => "..." irb(main):002:0> /#{a}/ => /.../ irb(main):003:0> /#{Regexp.escape(a)}/ => /\.\.\./ --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/