Regin allows you to introspect on Ruby Regexps.
Powered by an over the top regexp syntax parser written in racc/rexical.
Determine if a Regexp could be treated as a literal String
Regin.parse(/foo/).literal? # => true Regin.parse(/ba./).literal? # => false
Determine whether a character could match a part of a Regexp
Regin.parse(/foo\/bar/).include?("/") # => true Regin.parse(/foo.bar/).include?("/") # => true Regin.parse(/foo[a-z]bar/).include?("/") # => false
Extract a substring of a Regexp
Regin.parse(/foobar/)[3..6] => #<Expression "bar"> Regin.parse(/fo{2}[bB]ar/)[2..5] => #<Expression "[bB]ar">