From: Robert Dober Date: 2008-07-31T05:35:45+09:00 Subject: Re: Suggestions for improving a trivial tag parser On Wed, Jul 30, 2008 at 8:12 PM, Rolando Abarca wrote: > On 30-07-2008, at 13:53, Robert Dober wrote: > >> What about >> >> eles = split( %r{()} ).delete_if{|x| x.empty? } >> eles.size.one? ? eles.first : eles > > I think your regexp is wrong, since it (incorrectly) parses empty tags: It passed the specs did it not? I did not know what Gregory wanted exactly, turns out he wanted %r{()} but he got the message ;). > Now, I would bet that this might be a little too expensive with large > strings. Hmm why? It would be different if we were treating files, but as the string is already here we use the memory required by the specification and nothing more. Robert -- http://ruby-smalltalk.blogspot.com/ There's no one thing that's true. It's all true. -- Ernest Hemingway