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

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

Re: multiple alternatives regexp question


From: Jesper Harder
Subject: Re: multiple alternatives regexp question
Date: Wed, 07 Jan 2004 03:14:51 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Joe Corneli <jcorneli@math.utexas.edu> writes:

> Unfortunately, when I search and replace like so:
>
> (let ((case-fold-search nil))
> (while (re-search-forward "\\([[:lower:]]\\|[[:digit:]]\\|A\\)\\([A-Z]\\)"
>                           nil t)
>   (replace-match (concat (match-string 1) " " (match-string 2)))))
>
> on something like
>
> ProofOfPropertiesOfTraceOfAMatrix 
>
> I get back
>
> Proof Of Properties Of Trace Of AMatrix 
>                                  ^
> Why is the `A' not being treated the way I want the first time
> around?

It doesn't work because `replace-match' leaves point after the
replacement text.  You could use something like this instead:

   (replace-match "\\1 " t nil nil 1)


reply via email to

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