Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
データベースクエリを実行していて、クエリ結果で返された場合にのみ、文字列内の括弧をエスケープしたいと考えています。次に例を示します。
/これはテストストリングです (2013)/
どうすればいいですか?
すべての特殊文字がエスケープされた正規表現を作成するには、次を使用します。
Regexp.new( Regexp.escape(str) )
これがあなたが達成しようとしているものであることを願っています。