From: yvon.thoravalNO-SPAM@... (Yvon Thoraval) Date: 2004-10-05T17:59:51+09:00 Subject: Re: [yanq = yet another newbie question] correct syntax fovariable and regexp Robert Klemme wrote: > needle = ARGV[2] > rx = %r{^(.*)\s+#{needle}[\\s*|\\s+(.*)]} > > If you want to be sure that meta symbols in needle are not interpreted you > can do this: > > rx = %r{^(.*)\s+#{Regexp.escape needle}[\\s*|\\s+(.*)]} > > What strikes me odd is the rest of your regexp, especially the square > brackets. >If you just want to match a certain word as word in the line > you should probably use these ones: > > rx = %r{\b#{needle}\b} > rx = %r{\b#{Regexp.escape needle}\b} > > "\b" matches a word boundary. thanks for all, crystall clear to me �;) (i had forgotten the magic of "\b") and works great !!! -- yt