On Tue, Oct 19, 2004 at 11:08:35PM +0900, Peter Hickman wrote: > Eivind Eklund wrote: > > >From a practical use of Florian's code (his sample from Regexp::English): > > > > # Creates a Regexp which matches a literal string. In this > > # string any special regular expression meta-characters will > > # be escaped automatically. > > # > > # # This creates a Regexp which will match 3 "foo"s. > > # re = Regexp::English.literal("foo" * 3) > > # re.match("foofoofoo")[0] # => "foofoofoo" > > def literal(text); Node::Literal.new(text); end > > > >Translated to Nathaniel's syntax: > > > > # Creates a Regexp which matches a literal string. In this > > # string any special regular expression meta-characters will > > # be escaped automatically. > > example do > > # This creates a Regexp which will match 3 "foo"s. > > re = Regexp::English.literal("foo" * 3) > > assert_equal("foofoofoo", re.match("foofoofoo")[0]) > > end > > def literal(text); Node::Literal.new(text); end > > > >Note that this will also presently break rdoc, though there is an > >intention of later adding rdoc support. To avoid breaking with rdoc > >presently, you'd need to move the example BEFORE the comment. > > > If this were a voting thing I would go for Nathaniel's syntax as > Florian's looks like it is commented out and should not be run. > Besides how would you comment out something in Florian's syntax. Look carefully at the example: # # This creates a Regexp which will match 3 "foo"s. # re = Regexp::English.literal("foo" * 3) # re.match("foofoofoo")[0] # => "foofoofoo" -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com