From owner-freebsd-questions@FreeBSD.ORG Wed Sep 9 16:36:51 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 075291065670 for ; Wed, 9 Sep 2009 16:36:51 +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 D022A8FC12 for ; Wed, 9 Sep 2009 16:36:50 +0000 (UTC) Received: (qmail 12202 invoked from network); 9 Sep 2009 09:21:19 -0700 Received: by simscan 1.1.0 ppid: 12133, pid: 12136, t: 2.1575s 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=PKFI3LwSRKaNPrsfw4wA:9 a=yOUUobIxIB3e4jiW_1cA:7 a=gcxpFiMnxtC4YccuiaQRW3g6mFgA:4 Received: from unknown (HELO blacklamb.mykitchentable.net) (69.62.230.77) by smtp2 with SMTP; 9 Sep 2009 09:21:17 -0700 Received: from [127.0.0.1] (bigdaddy.mykitchentable.net [192.168.1.3]) by blacklamb.mykitchentable.net (Postfix) with ESMTPA id 29860165575 for ; Wed, 9 Sep 2009 09:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mykitchentable.net; s=default; t=1252514206; bh=8c5Q4c6uSQ50A9aeV4FajSoHrpacxfpP5MZEFVHmXlA=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=rGgMLn9yrfAPSaX0CGtpGXXbq/n8kOle8yLZ8hWMMS2bt4inDs3lmlEf97/+p04Di lvV+wc1A+5a8zm4difzm/oG2J6Ijk2bV17Bl9YcDckb1/wMfPT4wbAcvQI1fwEn9E6 W6bJn8NusSw+JWaSH7Q/xpxxINFWctSJk0J6Q71U= Message-ID: <4AA7D997.5040605@mykitchentable.net> Date: Wed, 09 Sep 2009 09:36:39 -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> <4AA7D89C.4020706@mykitchentable.net> In-Reply-To: <4AA7D89C.4020706@mykitchentable.net> 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:36:51 -0000 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