Newby asks: giving regexps as argument for funvtions

ts [mailto:decoux@moulon.inra.fr] assisted

If you want to give it a String

def findPosRE(str, re)
m = %r{#{re}}.match(str)
^^^^^^^^^^^^^

I get a syntax error here, sir Guy. If I replace the first nest {} with ()
(parens), it works fine. I’m running it on irb v0.7.4

···
  m.begin(0)

end

pos = findPosRE (“hey you behind the wall”, “behind”)

I get a syntax error here, sir Guy. If I replace the first nest {} with ()
(parens), it works fine. I'm running it on irb v0.7.4

pigeon% irb -v
irb 0.7.4(01/05/08)
pigeon%

pigeon% irb
irb(main):001:0> str = "aaa"
"aaa"
irb(main):002:0> re = "a"
"a"
irb(main):003:0> m = %r{#{re}}.match(str)
#<MatchData:0x40195ef4>
irb(main):004:0>
pigeon%

Guy Decoux