public
Description: Ruby Regexp syntax parser
Homepage: http://rdoc.info/projects/josh/reginald/
Clone URL: git://github.com/josh/reginald.git
name age message
file .gitignore Sun Dec 06 11:40:11 -0800 2009 generate rdoc [josh]
file LICENSE Sat Nov 07 13:53:35 -0800 2009 gem scaffolding [josh]
file README.rdoc Sun Dec 06 12:24:37 -0800 2009 sample usage in readme [josh]
file Rakefile Sun Dec 06 11:46:04 -0800 2009 nodoc parser [josh]
directory benchmark/ Sat Dec 05 09:35:10 -0800 2009 simplify and speed up cclass tokenizer [josh]
directory lib/ Sun Dec 06 12:09:18 -0800 2009 doc parse and compile [josh]
file reginald.gemspec Sun Dec 06 11:40:11 -0800 2009 generate rdoc [josh]
directory spec/ Sat Dec 05 11:00:24 -0800 2009 remove unknown regexp options example [josh]
README.rdoc

Reginald

Reginald is a Ruby Reginald syntax parser. Its parser and tokenizer are written in racc/rexical. Since racc is part of Ruby’s standard library, there are extra runtime dependencies.

Examples

Determine if a Regexp could be treated as a literal String

  Reginald.parse(/foo/).literal? # => true
  Reginald.parse(/ba./).literal? # => false

Determine whether a character could match a part of a Regexp

  Reginald.parse(/foo\/bar/).include?("/")    # => true
  Reginald.parse(/foo.bar/).include?("/")     # => true
  Reginald.parse(/foo[a-z]bar/).include?("/") # => false

Extract a substring of a Regexp

  Reginald.parse(/foobar/)[3..6] => #<Expression "bar">
  Reginald.parse(/fo{2}[bB]ar/)[2..5] => #<Expression "[bB]ar">