So I am looking at the Ruby API for sub and gsub.
I copied and pasted
"hello".sub(%r[aeiou]/, '*')
"hello".sub(%r([aeiou])/, '<\1>')

and to my surprise, they both result in an error.

1.9.3p194 :003 > "hello".sub(%r[aeiou]/, '*')
SyntaxError: (irb):3: syntax error, unexpected ','
"hello".sub(%r[aeiou]/, '*')
                       ^
(irb):3: syntax error, unexpected ')', expecting $end
  from /home/zrun/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'

Why?

-- 
Posted via http://www.ruby-forum.com/.