* Trouble with regexp
@ 2005-10-25 16:24 exits funnel
0 siblings, 0 replies; 10+ messages in thread
From: exits funnel @ 2005-10-25 16:24 UTC (permalink / raw)
Hello,
I have a text file with hundres of lines of the form:
%token FOO_Alter
where 'FOO' is always 'FOO' but 'Alter' is variable.
I'd like to convert these lines to:
t_foo_Alter = 'Alter';
using query-replace-regexp but I can't quite get it
right. Here's what I have so far:
M-x query-replace-regexp RET
%token XTAG_\(a-Z\) RET
t_xtag_\1 = '\1'; RET
Sadly, I get 0 occurences replaced. Can anyone set me
straight? Thanks in advance.
-exits
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.12639.1130257485.20277.help-gnu-emacs@gnu.org>]
* Trouble with regexp
@ 2008-05-22 16:00 TheLonelyStar
2008-05-22 16:47 ` Alan Mackenzie
0 siblings, 1 reply; 10+ messages in thread
From: TheLonelyStar @ 2008-05-22 16:00 UTC (permalink / raw)
To: Help-gnu-emacs
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 :(.
Thanks!
Nathan
--
View this message in context: http://www.nabble.com/Trouble-with-regexp-tp17407478p17407478.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Trouble with regexp
2008-05-22 16:00 TheLonelyStar
@ 2008-05-22 16:47 ` Alan Mackenzie
2008-05-22 17:27 ` Joel J. Adamson
0 siblings, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2008-05-22 16:47 UTC (permalink / raw)
To: TheLonelyStar; +Cc: Help-gnu-emacs
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.
> Thanks!
> Nathan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Trouble with regexp
2008-05-22 16:47 ` Alan Mackenzie
@ 2008-05-22 17:27 ` Joel J. Adamson
0 siblings, 0 replies; 10+ messages in thread
From: Joel J. Adamson @ 2008-05-22 17:27 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Help-gnu-emacs
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
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.12018.1211472045.18990.help-gnu-emacs@gnu.org>]
* Re: Trouble with regexp
[not found] <mailman.12018.1211472045.18990.help-gnu-emacs@gnu.org>
@ 2008-05-22 16:31 ` David Kastrup
0 siblings, 0 replies; 10+ messages in thread
From: David Kastrup @ 2008-05-22 16:31 UTC (permalink / raw)
To: help-gnu-emacs
TheLonelyStar <nabble@lonely-star.org> writes:
> 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 :(.
It does here. You are probably not doing the right quoting. Please
remember that the Lisp string syntax requires quoting of quote marks and
backslashes on _top_ of what quoting your regexps will need.
So please post the actual code that fails instead of talking about it.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-05-22 17:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25 16:24 Trouble with regexp exits funnel
[not found] <mailman.12639.1130257485.20277.help-gnu-emacs@gnu.org>
2005-10-25 17:16 ` rgb
2005-10-25 17:38 ` exits funnel
2005-10-25 17:54 ` Pascal Bourguignon
2005-10-25 18:40 ` exits funnel
2005-10-25 17:17 ` Chris McMahan
-- strict thread matches above, loose matches on Subject: below --
2008-05-22 16:00 TheLonelyStar
2008-05-22 16:47 ` Alan Mackenzie
2008-05-22 17:27 ` Joel J. Adamson
[not found] <mailman.12018.1211472045.18990.help-gnu-emacs@gnu.org>
2008-05-22 16:31 ` David Kastrup
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).