README.rdoc

Path: README.rdoc
Last Update: Tue Feb 05 11:41:57 -0500 2013

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

[Validate]