[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is wrong with this regexp search?
From: |
Mirko |
Subject: |
Re: What is wrong with this regexp search? |
Date: |
10 Nov 2006 10:53:11 -0800 |
User-agent: |
G2/1.0 |
Juanma Barranquero wrote:
> 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
Thank you to both of you. That was indeed the problem.
Mirko