正規表現
re = Regexp.new("abc*def") # /abc*def/ re2 = Regexp.new(Regexp.quote("abc*def") # /abc\*def/
となる
\s.. space
\d.. これはなんの略かね?
\w.. wordかな?
\Aとか\Zとかもあるがこれは"^"とか"$"とかとおなじ?
sub,sub!,gsub,gsub!,scanなどが基本
str = "abractabra" nstr = str.sub(/.a/){ |matched| "<" + matched.upcase + ">" } p nstr str.scan(/.a/){ |matched| p matched } str.scan(/(.)(a)/) { |matched| p matched }