|
From: | Juanma Barranquero |
Subject: | Re: What is wrong with this regexp search? |
Date: | Fri, 10 Nov 2006 17:50:25 +0100 |
On 10 Nov 2006 08:24:53 -0800, Mirko <mvukovic@nycap.rr.com> wrote:
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?
The variable `case-fold-search', I think. Try with: (defun camel-to-underline () (interactive) (let (case-fold-search) (while (re-search-forward "[a-z][A-Z]") (insert "_") (downcase-region (point) (+ 1 (point)))))) /L/e/k/t/u
[Prev in Thread] | Current Thread | [Next in Thread] |