Ruby Regexp Introspection
Pull request Compare This branch is even with pixeltrix:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benchmark
lib
spec
LICENSE
README.rdoc
Rakefile
regin.gemspec

README.rdoc

Regin

Regin allows you to introspect on Ruby Regexps.

Powered by an over the top regexp syntax parser written in racc/rexical.

Examples

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">