[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Re: svn commit: rev 163 - trunk/subversion/tests/clients/cmdline/svntest

From: Bill Tutt <rassilon_at_lyra.org>
Date: 2001-09-28 18:43:21 CEST

Yep, definitely.

Bill

"Though we are not now that strength that in old days moved Earth and
Heaven, that which we are we are; One equal temper of heroic hearts made
weak by time and fate but strong in will to strive, to seek, to find,
and not to yield." -- Tennyson

-----Original Message-----
From: Branko Cibej [mailto:brane@xbc.nu]
Sent: Friday, September 28, 2001 8:59 AM
To: Bill Tutt
Cc: Greg Stein; cmpilato@collab.net; dev@subversion.tigris.org
Subject: Re: svn commit: rev 163 -
trunk/subversion/tests/clients/cmdline/svntest

Bill Tutt wrote:

>A faster regular expression would be: "^(..)(.)([^\d]+)(\d+)\s+(.+)"
>In this case the the (\d+) would match 012345, and the enging wouldn't
>have to backtrack.
>
>Moral of the story:
>Always see if you can avoid using .* or .+ in the middle of a regular
>expression pattern, it degrades the matching performance of your
>regular expression.
>
>Secondary moral of the story:
>You're usually better off matching exactly what you're trying to match,

>and no more. Anything else can get you into trouble.
>
Right. So why not use:

    ^(..)(.)\s+(\*\s+)?(\d+)\s+(.+)$

You /know/ that the third column is an optional asterisk, so you might
as well say so explicitly. Then you can simply test for that with "$3 !=

undef", or whatever the Python equivalent is. And it make sense to
anchor the end of the regex; that doesn't change the way it matches, but

tells the reader that you really do want to match the whole line. That's

useful documentation, IMHO.

-- 
Brane Čibej   <brane_at_xbc.nu>            http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:42 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.