Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Sep 2009 09:36:39 -0700
From:      Drew Tomlinson <drew@mykitchentable.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: Regex Help - Greedy vs. Non-Greedy
Message-ID:  <4AA7D997.5040605@mykitchentable.net>
In-Reply-To: <4AA7D89C.4020706@mykitchentable.net>
References:  <4AA7D49D.8090002@mykitchentable.net>	<20090909162146.GB96342@torus.slightlystrange.org> <4AA7D89C.4020706@mykitchentable.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Drew Tomlinson wrote:
> Daniel Bye wrote:
>> On Wed, Sep 09, 2009 at 09:15:25AM -0700, Drew Tomlinson wrote:
>>  
>>> I'm trying to do a search and replace in vim.  I have lines like this:
>>> http://site1/dir/;
>>> http://site2/dir/;LastName, FirstName;Phone;
>>> http://site3/dir/;LastName, FirstName;
>>> http://site4/dir/;
>>>
>>> I'm want to match "http:*" and stop matching at the first ";".  My 
>>> basic regex is:
>>>
>>> /http:.\+;/
>>>
>>> But it's matching *all* the semi-colons.  Thus I've Googled and 
>>> tried various incatations to try and make my regex "non-greedy" but 
>>> I can't seem to come up with the correct combination.
>>>
>>> How can I write a regex that stops matching at the first semi-colon?
>>>     
>>
>> Tested in vi, not vim:
>>
>>  /http:[^;]*/
>>
>> Dan
>>   
>
> Thanks for your reply.  I tried it in vim (or more specifically, gvim 
> 7.2) and your example matches all semi-colons.  However in vi, it does 
> stop at the first semi-colon as you say.
>
> Can anyone please explain the difference?
>
> Thanks,
>
> Drew
>
Never mind.  My mistake.  The above does work in gvim.  I had a "." 
(dot) after http:.

Thanks Mel & Dan!

Cheers,

Drew

-- 
Be a Great Magician!
Visit The Alchemist's Warehouse

http://www.alchemistswarehouse.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AA7D997.5040605>