From: Bill Kelly Date: 2001-12-18T03:11:19+09:00 Subject: [ruby-talk:28813] Re: Scanning for delimited substrings From: "Martin DeMello" > > Martin DeMello wrote: > > Bill Kelly wrote: > > >> How about: > >> scan(/<<.*?>>|(?:.(?!<<))+/) > > >> irb(main):005:0> "fooa<>|(?:.(?!<<.*?>>))+/) > >> ["fooa< > Misbehaved on a few test cases - the problem was that it swallowed the last > character in the string before a delimiter pair. This one worked: > > m = "#{Regexp.quote(l)}.*?#{Regexp.quote(r)}" > s.scan(/#{m}|(?:.(?!#{m}))*./m) > > (changed the bit at the end from + to *.) Aiyeeeeeeee!!!! Shame on me =( http://www.foosenblat.org/ftp/wav/humiliation.wav Sorry. (That's what I get for writing a one-liner without any unit tests:) Regards, Bill