Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Sep 2009 17:21:46 +0100
From:      "Daniel Bye" <danielby@slightlystrange.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: Regex Help - Greedy vs. Non-Greedy
Message-ID:  <20090909162146.GB96342@torus.slightlystrange.org>
In-Reply-To: <4AA7D49D.8090002@mykitchentable.net>
References:  <4AA7D49D.8090002@mykitchentable.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--f2QGlHpHGjS2mn6Y
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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/;
>=20
> I'm want to match "http:*" and stop matching at the first ";".  My basic=
=20
> regex is:
>=20
> /http:.\+;/
>=20
> But it's matching *all* the semi-colons.  Thus I've Googled and tried=20
> various incatations to try and make my regex "non-greedy" but I can't=20
> seem to come up with the correct combination.
>=20
> How can I write a regex that stops matching at the first semi-colon?

Tested in vi, not vim:

 /http:[^;]*/

Dan

--=20
Daniel Bye
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \

--f2QGlHpHGjS2mn6Y
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (FreeBSD)

iEYEARECAAYFAkqn1hoACgkQixf5fBYiFmp4CwCfdwHoN+8z6TMnlGNdgSssx8D3
0q4AoL6jtpcdjsgOYJqzE6JIeHkkSxEe
=mD/3
-----END PGP SIGNATURE-----

--f2QGlHpHGjS2mn6Y--



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