From owner-freebsd-questions@FreeBSD.ORG Wed Sep 9 16:32:41 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EACC71065692 for ; Wed, 9 Sep 2009 16:32:41 +0000 (UTC) (envelope-from drew@mykitchentable.net) Received: from smtp2.mc.surewest.net (qsmtp.mc.surewest.net [66.60.130.145]) by mx1.freebsd.org (Postfix) with SMTP id C25CE8FC20 for ; Wed, 9 Sep 2009 16:32:41 +0000 (UTC) Received: (qmail 9637 invoked from network); 9 Sep 2009 09:17:07 -0700 Received: by simscan 1.1.0 ppid: 9617, pid: 9619, t: 2.1850s scanners: regex: 1.1.0 attach: 1.1.0 spam: 3.1.7-deb X-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on smtp2.surewest.net. X-Spam-Level: X-Spam-Status: No, score=0.0 required=13.5 tests=none autolearn=disabled version=3.1.7-deb X-Spam-CMAE-Analysis: v=1.0 c=1 a=kXY3MdDddYIA:10 a=jDt-9pEAAAAA:8 a=lcTVPu62-8YzZbtFj-QA:9 a=4XAYFD-83TM-hmmqOW8A:7 a=LXTZ7u_gDKMGrcDSzzY84yHwKgYA:4 Received: from unknown (HELO blacklamb.mykitchentable.net) (69.62.230.77) by smtp2 with SMTP; 9 Sep 2009 09:17:05 -0700 Received: from [127.0.0.1] (bigdaddy.mykitchentable.net [192.168.1.3]) by blacklamb.mykitchentable.net (Postfix) with ESMTPA id C916116557A for ; Wed, 9 Sep 2009 09:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mykitchentable.net; s=default; t=1252513954; bh=4RcKltBJq/gzlxJtwsfS+B4/a/AqDFFdHtgmUUPqcj0=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ZxiDp02dMw+T9mec+5CWsOusBTidNkgo67oYHtwoCrkDK7erP5B5+dcxZQ17z6Sv9 f+OrpbiqjHE3ZnexaaLS9opIN/t4gTmnsSSOv/EffiI/6FenMDtE8lTAFEPOkFxzSj zq/VqCAImrrXpm6wh/cUjqb9KJFGfSYBH+j8KZoM= Message-ID: <4AA7D89C.4020706@mykitchentable.net> Date: Wed, 09 Sep 2009 09:32:28 -0700 From: Drew Tomlinson User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <4AA7D49D.8090002@mykitchentable.net> <20090909162146.GB96342@torus.slightlystrange.org> In-Reply-To: <20090909162146.GB96342@torus.slightlystrange.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 090908-0, 09/08/2009), Outbound message X-Antivirus-Status: Clean Subject: Re: Regex Help - Greedy vs. Non-Greedy X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2009 16:32:42 -0000 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 -- Be a Great Magician! Visit The Alchemist's Warehouse http://www.alchemistswarehouse.com