From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Any performance comparison/guide of/for Emacs regex? Date: Tue, 18 Jan 2011 13:29:35 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1295376203 19743 80.91.229.12 (18 Jan 2011 18:43:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 Jan 2011 18:43:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 18 19:43:19 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PfGWR-0005ay-T8 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2011 19:43:16 +0100 Original-Received: from localhost ([127.0.0.1]:59680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfGWR-000194-6M for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2011 13:43:15 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 13 Injection-Info: mx03.eternal-september.org; posting-host="4IZ3yIHoQdnGHfrgR3wu6A"; logging-data="19584"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2XqoR87tPF7TSTDc2tk5s" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:WBNuNTzQV+wxYVo4gV9du6x5bjc= sha1:5vAGR21QEVtTqGC9ygX1QD25k2o= Original-Xref: usenet.stanford.edu gnu.emacs.help:184388 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78553 Archived-At: > Any performance comparison/guide of/for Emacs regex? Not really. What you need to know is that Emacs's regexp engine is based on backtracking, so things like .*\\(.*\\).* is insanely inefficient and will make you think Emacs is frozen. Generally, you'll prefer to use regexps that don't require backtracking. E.g. [^(\n]*( works much better than .*( since when encountering an open parenthesis, the matcher will know for sure that it has to leave the * loop, rather than having to try both cases in sequence. Stefan