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

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

multiple alternatives regexp question


From: Joe Corneli
Subject: multiple alternatives regexp question
Date: Tue, 06 Jan 2004 19:19:55 -0600

I am interested in a regexp that I think should be written
like this (for inclusion in a program):

"\\([[:lower:]]\\|[[:digit:]]\\|A\\)\\([A-Z]\\)"

In other words, a lower case letter, or a digit, or an `A',
followed by a capital letter.

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 
                                 ^

(Note that if you run the above code on the output string, it will
make a space in the appropriate place!)

Why is the `A' not being treated the way I want the first time
around?




reply via email to

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