From: "Brian F. Feldman" Date: 2001-10-24T04:10:34+09:00 Subject: [ruby-talk:23073] Re: splitting a string with nested elements Robert Feldt wrote: > On Wed, 24 Oct 2001, Joseph McDonald wrote: > > > Hi, > > > Hi, > > > Is there a way to do such a thing with a regex, or do I need to resort > > to a scanning technique, keeping track of the nested elements? > > > Nested comments is the canonical example of what can *NOT* be done with > regexps. But since I now said this I'm sure some smart ruby guru will tell > you it can be done anyway (I'm not fully aware of the difference between > RegularExpressions (the CS theory one) and their Perl and Ruby > implementations). > > BTW, the an upcoming version of Rockit will have an expanded > tokenizing/lexing/scanning formalism that can easily handle this. Writing a recursive-descent parser using regexes for string matching is a quite simple thing to do. So though a single regex alone plus Regexp#scan isn't enough, you can still do it in one method without major trouble :) -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------'