unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* What is wrong with this regexp search?
@ 2006-11-10 16:24 Mirko
  2006-11-10 16:46 ` rgb
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mirko @ 2006-11-10 16:24 UTC (permalink / raw)


Hello,

I am trying to write a command that will convert all occurance of a
lower case character followed by an uppercase character (such as kA)
into a sequance of lowercase characters separated by an underscore.
So, kA would go to k_a

This is my attempt:

(defun camel-to-underline ()
  (interactive)
  (while (re-search-forward "[a-z][A-Z]")
    (insert "_")
    (downcase-region (point) (+ 1 (point))) ) )

The problem is that re-search-forward seems to capture the very next
character, irrespective whether the following one is uppercase or
lowercase.

What am I missing?

Thanks,

Mirko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-10 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-10 16:24 What is wrong with this regexp search? Mirko
2006-11-10 16:46 ` rgb
2006-11-10 16:50 ` Juanma Barranquero
     [not found] ` <mailman.407.1163177433.2155.help-gnu-emacs@gnu.org>
2006-11-10 18:53   ` Mirko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).