* Regepxp-help: Replacing foo with bar but not foo.*
@ 2006-08-18 20:19 Patrick Drechsler
2006-08-18 20:34 ` Ralf Angeli
0 siblings, 1 reply; 4+ messages in thread
From: Patrick Drechsler @ 2006-08-18 20:19 UTC (permalink / raw)
Hi,
how do I replace the term `foo' with `bar' when `foo' is followed
by a conditional term? Or what do I have to pass as argument to
`M-x replace-string'?
the rule I'm trying to imply is "replace foo if it is not
followed by a dot".
INPUT
foo jfkda
foo.bar fdjak
OUTPUT
fooMYREPLACEMENT jfkda
foo.bar fdjak
TIA
Patrick
--
"If you choke a smurf, what color does it turn?"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Regepxp-help: Replacing foo with bar but not foo.*
2006-08-18 20:19 Regepxp-help: Replacing foo with bar but not foo.* Patrick Drechsler
@ 2006-08-18 20:34 ` Ralf Angeli
2006-08-18 21:07 ` Eric Hanchrow
2006-08-19 14:48 ` Patrick Drechsler
0 siblings, 2 replies; 4+ messages in thread
From: Ralf Angeli @ 2006-08-18 20:34 UTC (permalink / raw)
* Patrick Drechsler (2006-08-18) writes:
> the rule I'm trying to imply is "replace foo if it is not
> followed by a dot".
>
> INPUT
>
> foo jfkda
> foo.bar fdjak
>
> OUTPUT
>
> fooMYREPLACEMENT jfkda
> foo.bar fdjak
C-M-% foo\([^.]\) RET fooMYREPLACEMENT\1
--
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Regepxp-help: Replacing foo with bar but not foo.*
2006-08-18 20:34 ` Ralf Angeli
@ 2006-08-18 21:07 ` Eric Hanchrow
2006-08-19 14:48 ` Patrick Drechsler
1 sibling, 0 replies; 4+ messages in thread
From: Eric Hanchrow @ 2006-08-18 21:07 UTC (permalink / raw)
and for what it's worth, if you want to write the regular expression
in Emacs Lisp code (as opposed to typing it directly to M-x
replace-regexp), you could use
(rx "foo" (group (not (any "."))))
--
Rarely do we find men who willingly engage in hard, solid
thinking. There is an almost universal quest for easy answers
and half-baked solutions. Nothing pains some people more
than having to think.
-- Martin Luther King, Jr.
from "Strength to Love," 1963.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Regepxp-help: Replacing foo with bar but not foo.*
2006-08-18 20:34 ` Ralf Angeli
2006-08-18 21:07 ` Eric Hanchrow
@ 2006-08-19 14:48 ` Patrick Drechsler
1 sibling, 0 replies; 4+ messages in thread
From: Patrick Drechsler @ 2006-08-19 14:48 UTC (permalink / raw)
Ralf Angeli wrote on 18 Aug 2006 21:34:04 MET:
> * Patrick Drechsler (2006-08-18) writes:
>
>> the rule I'm trying to imply is "replace foo if it is not
>> followed by a dot".
>>
>> INPUT
>>
>> foo jfkda
>> foo.bar fdjak
>>
>> OUTPUT
>>
>> fooMYREPLACEMENT jfkda
>> foo.bar fdjak
>
> C-M-% foo\([^.]\) RET fooMYREPLACEMENT\1
Ralf and Eric, thank you both for your answers!
Cheers
Patrick
--
DJ:"You may not say YES,NO,BLACK,WHITE. OK, let's start. Are you still
sober?"
Caller: "No."
Friday night radio documents the search for intelligence
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-19 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-18 20:19 Regepxp-help: Replacing foo with bar but not foo.* Patrick Drechsler
2006-08-18 20:34 ` Ralf Angeli
2006-08-18 21:07 ` Eric Hanchrow
2006-08-19 14:48 ` Patrick Drechsler
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).