[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trouble with regexp
From: |
Joel J. Adamson |
Subject: |
Re: Trouble with regexp |
Date: |
Thu, 22 May 2008 13:27:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Alan Mackenzie <acm@muc.de> writes:
> Hi, TLS!
>
> On Thu, 22 May 2008, TheLonelyStar wrote:
>
>
>> Hi,
>
>> I some trouble with regular expression. I thought, the regexp "\(foo\|bar\)"
>> should match either foo and bar.
>> But if I have a buffer with "foo" in it, the regexp build does not match it
>> with that :(.
>
> Are you sure your regexp is what you think it is? If you are typing
> it into an elisp program, you need to write:
>
> "\\(foo\\|bar\\)"
>
> . If you've done C-M-s and are typing into the minibuffer, you don't
> double the quotes.
I think the problem is he's using re-builder, and expecting it to work
the same as regexp Isearch. If I enter this
"\\(some\\|with\\|regexp\\)"
in re-builder, then I get some matches. Without the double backslashes
and quoting, it won't match.
But in Regexp Isearch
\(some\|with\|regexp\)
does match. Confusing, yes, but useful nevertheless.
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
Public key: http://pgp.mit.edu
http://www.unc.edu/~adamsonj