詳細
正規表現の利用時にエスケープが必要な文字にバックスラッシュを付与する。
サンプルコード
puts Regexp.escape('.*?/+-{}()abc') puts Regexp.quote('.*?/+-{}()abc')
出力
\.\*\?/\+\-\{\}\(\)abc \.\*\?/\+\-\{\}\(\)abc
正規表現の利用時にエスケープが必要な文字にバックスラッシュを付与する。
puts Regexp.escape('.*?/+-{}()abc') puts Regexp.quote('.*?/+-{}()abc')
\.\*\?/\+\-\{\}\(\)abc \.\*\?/\+\-\{\}\(\)abc