Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Regexpクラス > try_convert
try_convert(obj) -> re | nil
Try to convert obj into a Regexp, using to_regexp method. Returns converted regexp or nil if obj cannot be converted for any reason.
Regexp.try_convert(/re/) # => /re/ Regexp.try_convert("re") # => nil