[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 <monnier@iro.umontreal.ca>
wrote:
>> 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.
Edi.
- delete text block with regexp, Herbert Fritsch, 2003/11/16
- Re: delete text block with regexp, Oliver Scholz, 2003/11/16
- Re: delete text block with regexp, Alex Schroeder, 2003/11/16
- Re: delete text block with regexp, Stefan Monnier, 2003/11/16
- Re: delete text block with regexp,
Edi Weitz <=
- Re: delete text block with regexp, Stefan Monnier, 2003/11/17
- Re: delete text block with regexp, Edi Weitz, 2003/11/17
- Re: delete text block with regexp, Stefan Monnier, 2003/11/17
- Re: delete text block with regexp, Oliver Scholz, 2003/11/17
- Re: delete text block with regexp, Edi Weitz, 2003/11/17