help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Why are RegExps never working?


From: Peter Dyballa
Subject: Re: Why are RegExps never working?
Date: Sun, 11 Nov 2007 15:47:52 +0100


Am 11.11.2007 um 15:06 schrieb Sven Bretfeld:

pp\.[ \|$][0-9]

To my understanding, it should mean: the string pp. followed by a
group consisting of space or end-of-line followed by a number.

...

What's my mistake?

You mean: what *are* ?

Everything between square brackets, i.e. in [], are alternatives, no | is needed.

What you are trying to search and destroy, ahhem, replace are not line endings but line feeds inside the from expression. These are put into the expression as C-q C-j. The expression between [] won't look like such, but I can give you some guarantee: it works! Definitely.


And please read again what a "group" in regular expressions is! The `` [ \|$]´´ and the ``[0-9]´´ are bracket expressions, a faulty (for your purpose) and a working one. If you want to re-use parts of the search expression you can use:

        \(pp\.\)[ ^J]\([0-9]\)  ->  \1~\2

Line feed or SPC are converted to ~.

--
Mit friedvollen Grüßen

  Pete

Well done is better than well said.
                           -- Benjamin Franklin


Attachment: PGP.sig
Description: Signierter Teil der Nachricht


reply via email to

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