* replace-regexp-in-string bug?
@ 2005-08-13 12:17 Lennart Borgman
2005-08-13 12:37 ` Lennart Borgman
2005-08-13 13:49 ` Andreas Schwab
0 siblings, 2 replies; 3+ messages in thread
From: Lennart Borgman @ 2005-08-13 12:17 UTC (permalink / raw)
I want to create a regexp out of an unknown string with spaces. I am not
sure about the number of spaces in the actual string to match so I want
to do a replacement like this:
(replace-regexp-in-string "\s-+" "\s-+" "some space" nil t)
However this returns "some space" instead of "some\s-+space" which I
expected. Is this a bug or am I misunderstanding the arguments in some way?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: replace-regexp-in-string bug?
2005-08-13 12:17 replace-regexp-in-string bug? Lennart Borgman
@ 2005-08-13 12:37 ` Lennart Borgman
2005-08-13 13:49 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Lennart Borgman @ 2005-08-13 12:37 UTC (permalink / raw)
Cc: Emacs Devel
Lennart Borgman wrote:
> I want to create a regexp out of an unknown string with spaces. I am
> not sure about the number of spaces in the actual string to match so I
> want to do a replacement like this:
>
> (replace-regexp-in-string "\s-+" "\s-+" "some space" nil t)
>
> However this returns "some space" instead of "some\s-+space" which I
> expected. Is this a bug or am I misunderstanding the arguments in some
> way?
No, it was not a bug. I have to count my \. This works as expected using
(replace-regexp-in-string "\\s-+" "\\s-+" "some space" nil t)
Sorry for the noise.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: replace-regexp-in-string bug?
2005-08-13 12:17 replace-regexp-in-string bug? Lennart Borgman
2005-08-13 12:37 ` Lennart Borgman
@ 2005-08-13 13:49 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2005-08-13 13:49 UTC (permalink / raw)
Cc: Emacs Devel
Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
> (replace-regexp-in-string "\s-+" "\s-+" "some space" nil t)
"\s-+" is the same as "s-+". You need to use the proper read syntax for
strings, see "Syntax for Strings" in the Emacs Lisp manual.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-13 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-13 12:17 replace-regexp-in-string bug? Lennart Borgman
2005-08-13 12:37 ` Lennart Borgman
2005-08-13 13:49 ` Andreas Schwab
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).