|
From: | Peter Dyballa |
Subject: | Re: multiline regex mode? |
Date: | Sat, 25 Nov 2006 14:14:05 +0100 |
Am 25.11.2006 um 04:01 schrieb Dieter Wilhelm:
So "{[^}]*}" stands for 'a region that starts with `{´ and has no `}´ until the final `}´ is hit; between both braces any number (starting with 0) of any character except `}´ can appear.'Thanks Peter for the hassle. Maybe I expressed myself in a confusing manner: The period and the character alternatives I understand. What I really wanted to know is where to look for a possibility of searching for *balanced* brackets like { { } } because I'll need this in my own Elisp stuff. It's clear that there is some code in Emacs for it (e. g. C-M-f etc.) but I have a hunch that there might be something else out there. Maybe a regexp extension in Perl or ...
I think you can't use one regular expression for a variety of nested "*balanced* brackets like { { } }".
A simple regexp would be: find a region that starts after `{´ and has neither `}´ nor `{´
until it reaches the first `}´: {[^{}]*}It's obvious that it can't find your case. Before and after the previous case from above this previous case has to be repeated. Let's try this:
{[^{}]*·{[^{}]*}·[^{}]*} ; the · might help to understand, they are not meant to be parts of the regexp! So remove them before trying to use it!
{ and no { or }, then { and no { or }, then }, and no { or }, but a final }.
You can find the { { { } } } case ... or the { { } { } } case or ... And you would need to find an algorithm in which sequence to apply them!
Perl won't help. It has the same restrictions (or it wouldn't handle basic or extended regular expressions). It's only possible to use a more complicated syntax that less people would try to understand.
-- Mit friedvollen Grüßen PeteWindows, c'est un peu comme le beaujolais nouveau: à chaque nouvelle cuvée on sait que ce sera dégueulasse, mais on en prend quand même, par masochisme.
[Prev in Thread] | Current Thread | [Next in Thread] |