From: Jason Voegele Date: 2002-02-13T22:56:41+09:00 Subject: Re: simple XML parsing (greedy / non-greedy > On Wed, 13 Feb 2002 12:06:49 GMT, David Alan Black > wrote: > >>On Wed, 13 Feb 2002, Ron Jeffries wrote: >>> Is there a way to tell the match operator to stop on the earliest >>> match? >> >>Yes -- just use *? instead of * > > Thanks ... I see that that works. But I don't see why. Once the ? is in > effect, does the whole regexp become non-greedy and quit on the first > match? (This must be approximately the case, or it wouldn't be > working.) That occurrence of the * operator becomes non-greedy. Other occurrences remain greedy unless followed by a '?'. > What should I have read to know this? The pickaxe book has this to say (in chapter "The Ruby Language"): "re ? Matches zero or one occurrence of re. The *, +, and {m,n} modifiers are greedy by default. Append a question mark to make them minimal." Temporary URL while rubycentral is not available: http://rubycentral.rubynet.org/book/language.html Jason Voegele