[Tutor] stopping greedy matches

Kent Johnson kent37 at tds.net
Thu Mar 17 21:18:39 CET 2005


Mike Hall wrote:
> 
> On Mar 17, 2005, at 11:11 AM, Kent Johnson wrote:
> 
>> The first one matches the space after 'in'. Without it the .+? will 
>> match the single space, then \b matches the *start* of the next word.
> 
> 
> I think I understand. Basically the first dot advances the pattern 
> forward in order to perform a non-greedy match on the following word.(?) 
> Very nice.

That's right. The first dot could just as well be a space or \s or maybe even \s+ (to match any 
amount of white space). I actually used the dot because I thought it would be clearer than a space :-)

Kent



More information about the Tutor mailing list