Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby Regexp Introspection
Ruby
Failed to load latest commit information.
benchmark cleanup and speedup expression reducing
lib Fix lookahead assertions
spec Fix lookahead assertions
LICENSE update copyright year to 2010
README.rdoc Regin 0.3.0
Rakefile Upgrade to RSpec 2
regin.gemspec Regin 0.3.8

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">
Something went wrong with that request. Please try again.