* How does one avoid matching \n when matching all but whitespace?
@ 2007-07-07 19:59 ld1976
2007-07-07 21:26 ` Stephen Berman
0 siblings, 1 reply; 3+ messages in thread
From: ld1976 @ 2007-07-07 19:59 UTC (permalink / raw)
To: Help-gnu-emacs
Hello all. This is a rookie's question.
I am trying to a simple text regular expression replacement.
The text goes as follows (white spaces may change:
tcl_cmd bla > kuku
I want to change it to:
tcl_cmd bla > kuku.rev1
When trying to use replace-regexp \(>[ ]+[^ ]+\) to \1.rev1 I get:
tcl_cmd bla > kuku
.rev1
This is quiet different than using the \W+ with perl...
I think that emacs matches within [^ ]+ \n too. Trying to use [^ \n]+ did
not solve the issue either.
Any thoughts?
-Lior
--
View this message in context: http://www.nabble.com/How-does-one-avoid-matching-%5Cn-when-matching-all-but-whitespace--tf4041646.html#a11481693
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does one avoid matching \n when matching all but whitespace?
2007-07-07 19:59 How does one avoid matching \n when matching all but whitespace? ld1976
@ 2007-07-07 21:26 ` Stephen Berman
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Berman @ 2007-07-07 21:26 UTC (permalink / raw)
To: help-gnu-emacs
On Sat, 7 Jul 2007 12:59:31 -0700 (PDT) ld1976 <lior_dagan@yahoo.com> wrote:
> Hello all. This is a rookie's question.
> I am trying to a simple text regular expression replacement.
> The text goes as follows (white spaces may change:
> tcl_cmd bla > kuku
> I want to change it to:
> tcl_cmd bla > kuku.rev1
> When trying to use replace-regexp \(>[ ]+[^ ]+\) to \1.rev1 I get:
> tcl_cmd bla > kuku
> .rev1
> This is quiet different than using the \W+ with perl...
> I think that emacs matches within [^ ]+ \n too. Trying to use [^ \n]+ did
> not solve the issue either.
With replace-regexp you need to type C-q C-j instead of \n to match a
newline. (Emacs 22.1 gives you a hint to that effect when you type
`\n' in the regexp.)
Steve Berman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does one avoid matching \n when matching all but whitespace?
[not found] <mailman.3168.1183840964.32220.help-gnu-emacs@gnu.org>
@ 2007-07-08 12:38 ` Tyler Smith
0 siblings, 0 replies; 3+ messages in thread
From: Tyler Smith @ 2007-07-08 12:38 UTC (permalink / raw)
To: help-gnu-emacs
On 2007-07-07, ld1976 <lior_dagan@yahoo.com> wrote:
>
> Hello all. This is a rookie's question.
> I am trying to a simple text regular expression replacement.
> The text goes as follows (white spaces may change:
> tcl_cmd bla > kuku
> I want to change it to:
> tcl_cmd bla > kuku.rev1
> When trying to use replace-regexp \(>[ ]+[^ ]+\) to \1.rev1 I get:
> tcl_cmd bla > kuku
> .rev1
> This is quiet different than using the \W+ with perl...
You could do it (almost) the same way you'd do it in perl:
'\(> +\w+\)' to '\1.rev1'
You can also use '$' to explicitly signal the end of line, which is
helpful if you have other incidences of '> ' that occur earlier in the
line:
'\(> +\w+\)$' to '\1.rev1'
HTH,
Tyler
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-08 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-07 19:59 How does one avoid matching \n when matching all but whitespace? ld1976
2007-07-07 21:26 ` Stephen Berman
[not found] <mailman.3168.1183840964.32220.help-gnu-emacs@gnu.org>
2007-07-08 12:38 ` Tyler Smith
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.