all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* removing spaces from a string
@ 2006-04-19  9:02 Peter Tury
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Tury @ 2006-04-19  9:02 UTC (permalink / raw)


Hi,

how can I most simply remove all spaces from a string? I plan to have a
variable what holds the string, so functions what operates on regions,
rectangles or any parts of a buffer, etc. are not good (I guess).

I would need something like this: (remove-all-space a-sting-var); if e.g.
(setq a-string-var "abcd ef   dg ") then this should return "abcdefdg" what
I will pass forward to another function (namely: process-send-string).

Thanks!
P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
@ 2006-04-19 10:01 LENNART BORGMAN
  0 siblings, 0 replies; 11+ messages in thread
From: LENNART BORGMAN @ 2006-04-19 10:01 UTC (permalink / raw)
  Cc: help-gnu-emacs

From: Peter Tury <tury.peter@gmail.com>
Date: Wednesday, April 19, 2006 11:02 am
Subject: removing spaces from a string

> Hi,
> 
> how can I most simply remove all spaces from a string? I plan to 
> have a
> variable what holds the string, so functions what operates on regions,
> rectangles or any parts of a buffer, etc. are not good (I guess).
> 
> I would need something like this: (remove-all-space a-sting-var); 
> if e.g.
> (setq a-string-var "abcd ef   dg ") then this should return 
> "abcdefdg" what
> I will pass forward to another function (namely: process-send-string).
> 
> Thanks!
> P
> 

Maybe use replace-regexp-in-string?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
       [not found] <mailman.561.1145441329.9609.help-gnu-emacs@gnu.org>
@ 2006-04-19 10:43 ` Peter Tury
  2006-04-19 11:42   ` David Kastrup
  2006-04-19 17:30   ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Peter Tury @ 2006-04-19 10:43 UTC (permalink / raw)


On Wed, 19 Apr 2006 12:01:21 +0200, LENNART BORGMAN wrote:

> From: Peter Tury <tury.peter@gmail.com>
> Date: Wednesday, April 19, 2006 11:02 am
> Subject: removing spaces from a string
> 
>> Hi,
>> 
>> how can I most simply remove all spaces from a string? I plan to 
>> have a
>> variable what holds the string, so functions what operates on regions,
>> rectangles or any parts of a buffer, etc. are not good (I guess).
>> 
>> I would need something like this: (remove-all-space a-sting-var); 
>> if e.g.
>> (setq a-string-var "abcd ef   dg ") then this should return 
>> "abcdefdg" what
>> I will pass forward to another function (namely: process-send-string).
>> 
>> Thanks!
>> P
>> 
> 
> Maybe use replace-regexp-in-string?

Thanks! I looked exactly for this one. Unfortunately I couldn't find it
(using C-h a ..., and browsing the emacs and elisp manuals... -- now I see
I should have used C-h d ...?)

Thanks,
P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 10:43 ` Peter Tury
@ 2006-04-19 11:42   ` David Kastrup
  2006-04-19 12:49     ` Pascal Bourguignon
  2006-04-19 17:30   ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: David Kastrup @ 2006-04-19 11:42 UTC (permalink / raw)


Peter Tury <tury.peter@gmail.com> writes:

> On Wed, 19 Apr 2006 12:01:21 +0200, LENNART BORGMAN wrote:
>
>> From: Peter Tury <tury.peter@gmail.com>
>> Date: Wednesday, April 19, 2006 11:02 am
>> Subject: removing spaces from a string
>> 
>>> Hi,
>>> 
>>> how can I most simply remove all spaces from a string? I plan to 
>>> have a
>>> variable what holds the string, so functions what operates on regions,
>>> rectangles or any parts of a buffer, etc. are not good (I guess).
>>> 
>>> I would need something like this: (remove-all-space a-sting-var); 
>>> if e.g.
>>> (setq a-string-var "abcd ef   dg ") then this should return 
>>> "abcdefdg" what
>>> I will pass forward to another function (namely: process-send-string).
>>> 
>>> Thanks!
>>> P
>>> 
>> 
>> Maybe use replace-regexp-in-string?
>
> Thanks! I looked exactly for this one. Unfortunately I couldn't find it
> (using C-h a ..., and browsing the emacs and elisp manuals... -- now I see
> I should have used C-h d ...?)

It is also possible to do
(concat (delq ?\  (append "This is a string" nil)))

Or a number of other approaches.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 11:42   ` David Kastrup
@ 2006-04-19 12:49     ` Pascal Bourguignon
  2006-04-19 13:11       ` David Kastrup
  2006-04-19 15:06       ` Peter Tury
  0 siblings, 2 replies; 11+ messages in thread
From: Pascal Bourguignon @ 2006-04-19 12:49 UTC (permalink / raw)


David Kastrup <dak@gnu.org> writes:
> Peter Tury <tury.peter@gmail.com> writes:
>> On Wed, 19 Apr 2006 12:01:21 +0200, LENNART BORGMAN wrote:
>>> From: Peter Tury <tury.peter@gmail.com>
>>>> I would need something like this: (remove-all-space a-sting-var); 
>>> Maybe use replace-regexp-in-string?
>>
>> Thanks! I looked exactly for this one. Unfortunately I couldn't find it
>> (using C-h a ..., and browsing the emacs and elisp manuals... -- now I see
>> I should have used C-h d ...?)
>
> It is also possible to do
> (concat (delq ?\  (append "This is a string" nil)))
>
> Or a number of other approaches.

Merely:  (delete ?  "ab cd  ef") --> "abcdef"

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 12:49     ` Pascal Bourguignon
@ 2006-04-19 13:11       ` David Kastrup
  2006-04-19 15:06       ` Peter Tury
  1 sibling, 0 replies; 11+ messages in thread
From: David Kastrup @ 2006-04-19 13:11 UTC (permalink / raw)


Pascal Bourguignon <pjb@informatimago.com> writes:

> David Kastrup <dak@gnu.org> writes:
>> Peter Tury <tury.peter@gmail.com> writes:
>>> On Wed, 19 Apr 2006 12:01:21 +0200, LENNART BORGMAN wrote:
>>>> From: Peter Tury <tury.peter@gmail.com>
>>>>> I would need something like this: (remove-all-space a-sting-var); 
>>>> Maybe use replace-regexp-in-string?
>>>
>>> Thanks! I looked exactly for this one. Unfortunately I couldn't find it
>>> (using C-h a ..., and browsing the emacs and elisp manuals... -- now I see
>>> I should have used C-h d ...?)
>>
>> It is also possible to do
>> (concat (delq ?\  (append "This is a string" nil)))
>>
>> Or a number of other approaches.
>
> Merely:  (delete ?  "ab cd  ef") --> "abcdef"

Oops.  Didn't know about that delq/delete asymmetry.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 12:49     ` Pascal Bourguignon
  2006-04-19 13:11       ` David Kastrup
@ 2006-04-19 15:06       ` Peter Tury
  2006-04-19 15:39         ` Giorgos Keramidas
  2006-04-19 19:30         ` Pascal Bourguignon
  1 sibling, 2 replies; 11+ messages in thread
From: Peter Tury @ 2006-04-19 15:06 UTC (permalink / raw)


On Wed, 19 Apr 2006 14:49:37 +0200, Pascal Bourguignon wrote:

> David Kastrup <dak@gnu.org> writes:
>> Peter Tury <tury.peter@gmail.com> writes:
>>> On Wed, 19 Apr 2006 12:01:21 +0200, LENNART BORGMAN wrote:
>>>> Maybe use replace-regexp-in-string?
>>>
>> (concat (delq ?\  (append "This is a string" nil)))
>>
> Merely:  (delete ?  "ab cd  ef") --> "abcdef"

Thanks for all the good, the nicer and the even nicer solutions :-))

I didn't hope that I can learn such many things from such a simple problem.

And finally I found them (delq and delete) at the list functions'
description in the elisp manual (I checked only the string, the array and
sequence functions before posting my original question :-(

How to interpret ?\ ? Where can I learn about this?

Thanks again!!
P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 15:06       ` Peter Tury
@ 2006-04-19 15:39         ` Giorgos Keramidas
  2006-04-19 16:02           ` Peter Tury
  2006-04-19 19:30         ` Pascal Bourguignon
  1 sibling, 1 reply; 11+ messages in thread
From: Giorgos Keramidas @ 2006-04-19 15:39 UTC (permalink / raw)


On Wed, 19 Apr 2006 15:06:32 GMT, Peter Tury <tury.peter@gmail.com> wrote:
> On Wed, 19 Apr 2006 14:49:37 +0200, Pascal Bourguignon wrote:
>> Merely:  (delete ?  "ab cd  ef") --> "abcdef"
>
> Thanks for all the good, the nicer and the even nicer solutions :-))
>
> I didn't hope that I can learn such many things from such a simple problem.
>
> And finally I found them (delq and delete) at the list functions'
> description in the elisp manual (I checked only the string, the array and
> sequence functions before posting my original question :-(
>
> How to interpret ?\ ? Where can I learn about this?

It's a character constant (the SPC character in this case):

M-x info RET g (elisp)Character Type RET

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 15:39         ` Giorgos Keramidas
@ 2006-04-19 16:02           ` Peter Tury
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Tury @ 2006-04-19 16:02 UTC (permalink / raw)


On Wed, 19 Apr 2006 18:39:09 +0300, Giorgos Keramidas wrote:

> On Wed, 19 Apr 2006 15:06:32 GMT, Peter Tury <tury.peter@gmail.com> wrote:
>> How to interpret ?\ ? Where can I learn about this?
> 
> It's a character constant (the SPC character in this case):
> 
> M-x info RET g (elisp)Character Type RET

Thanks!! Now I see (again:-) it is worth reading of the beginning (of a
manual) not only the middle ;-)

I asked this because I didn't know if there is any difference between ?
and ?\ . Now I see there isn't. These are all the same: ? , ?\ , ?\s. (And
the last one is the preferred according to the elisp manual :-)

Thanks again,
P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 10:43 ` Peter Tury
  2006-04-19 11:42   ` David Kastrup
@ 2006-04-19 17:30   ` Eli Zaretskii
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2006-04-19 17:30 UTC (permalink / raw)


> From: Peter Tury <tury.peter@gmail.com>
> Date: Wed, 19 Apr 2006 10:43:22 GMT
> 
> > Maybe use replace-regexp-in-string?
> 
> Thanks! I looked exactly for this one. Unfortunately I couldn't find it
> (using C-h a

C-h a is only for commands.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: removing spaces from a string
  2006-04-19 15:06       ` Peter Tury
  2006-04-19 15:39         ` Giorgos Keramidas
@ 2006-04-19 19:30         ` Pascal Bourguignon
  1 sibling, 0 replies; 11+ messages in thread
From: Pascal Bourguignon @ 2006-04-19 19:30 UTC (permalink / raw)


Peter Tury <tury.peter@gmail.com> writes:
> How to interpret ?\ ?  Where can I learn about this?

I assume in the elisp info documentation.

(info "(elisp)Character Type")

Note that ?\x interprets x specially,
while     ?x  interprets x literally.

It just happens that ?\   (? \ SPC) falls in the default case of ?\,
where its interpreted as space.  But ?\a is not ?a.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-04-19 19:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-19  9:02 removing spaces from a string Peter Tury
  -- strict thread matches above, loose matches on Subject: below --
2006-04-19 10:01 LENNART BORGMAN
     [not found] <mailman.561.1145441329.9609.help-gnu-emacs@gnu.org>
2006-04-19 10:43 ` Peter Tury
2006-04-19 11:42   ` David Kastrup
2006-04-19 12:49     ` Pascal Bourguignon
2006-04-19 13:11       ` David Kastrup
2006-04-19 15:06       ` Peter Tury
2006-04-19 15:39         ` Giorgos Keramidas
2006-04-19 16:02           ` Peter Tury
2006-04-19 19:30         ` Pascal Bourguignon
2006-04-19 17:30   ` Eli Zaretskii

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.