Regexp.try_convert(obj) â re or nil
Class Public methods
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 o = Object.new Regexp.try_convert(o) #=> nil def o.to_regexp() /foo/ end Regexp.try_convert(o) #=> /foo/
Please login to continue.