[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete text block with regexp

From: Edi Weitz
Subject: Re: delete text block with regexp
Date: Mon, 17 Nov 2003 01:32:14 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

On Sun, 16 Nov 2003 23:42:37 GMT, Stefan Monnier <> 

>> The critical part is that "." matches anything but a newline.
>> Therefore use "\(.\|\n\)" for any character or a newline.
> Beware: such a regexp tends to suffer from the "regexp stack
> overflow" problem.  Better use \(.*\n\)*.* which is equivalent but
> uses a lot less stack space.
> Sadly, to understand why you need to understand details of how the
> regexp matching happens to be implemented in Emacs.

Shouldn't a good regex implementation be able to optimize the problem
away in simple cases like this? I've written a regex engine for Common
Lisp which does transformations like (Perl syntax)

  <regex>*   ->   (?:<regex'>*<regex>)?
  <regex>+   ->   <regex'>*<regex>

if <regex> includes register groups and is of fixed length. <regex'>
is an equivalent regular expression but without the register
groups. I'm pretty sure Perl does something similar.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]