On Wed, 13 Feb 2002 12:06:49 GMT, David Alan Black
<dblack / candle.superlink.net> wrote:

>On Wed, 13 Feb 2002, Ron Jeffries wrote:
>
>> Suppose I had this text
>>
>> 	'<a>this is a</a><a>this is a also</a>'
>>
>> and I wanted to write a regexp that would match the tag <a>..</a> and
>> return
>>
>> 	'this is a'
>> 	(not 'this is a</a><a>this is a also')
>>
>> I'd sort of like to use a pattern like
>>
>> Regexp.new( '<a>(.*)</a>' ), but this is greedy and matches as far as it
>> can.
>>
>> 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.)

Anyway, thanks ... if I treat it as magic it'll work. 

What should I have read to know this? 

Thanks!

Ronald E Jeffries
http://www.XProgramming.com
http://www.objectmentor.com
I'm giving the best advice I have. You get to decide whether it's true for you.