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

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

What is wrong with this regexp search?


From: Mirko
Subject: What is wrong with this regexp search?
Date: 10 Nov 2006 08:24:53 -0800
User-agent: G2/1.0

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



reply via email to

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