MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: trimming a string

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50866] Re: trimming a string
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 25 Sep 2004 01:55:04 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <cj0ngc$les$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

StringTrim[s_String] := 
  StringJoin @@ (Characters[s] //. {" ", a___} :> {a} //. {a__, " "} :>
{a})

somestring = "    Humpty Dumpty   ";

StringTrim[somestring]

??

Regards
  Jens

Akos Beleznay wrote:
> 
> I would appreciate if somebody could show me a simple way of trimming a
> string. (I did it a hard way, but suspect an elegant solution.)
> 
> Trim(a_string): returns a copy of a string without leading and trailing
> spaces.
> 
> thanks for your help,
> 
> Akos Beleznay
> Equitas Capital Advisors LLC
> 909 Poydras Street
> Suite 1850
> New Orleans, LA 70112
> Phone: (504) 569-9607
> Fax: (504) 569-9650
> abeleznay at equitas-capital.com
> 
> This email is intended for the sole use of the intended recipient(s) and may contain confidential or privileged information. No one is authorized to copy or re-use this email or any information contained in it. If you are not the intended recipient, we request that you please notify us by reply email and destroy all copies of the message and any attachments. PAFA reserves the right to monitor and review the content of all e-mail communications sent and/or received by its affiliates. Thank you for your cooperation.


  • Prev by Date: Minimization problem
  • Next by Date: FindMinimum
  • Previous by thread: Re: trimming a string
  • Next by thread: Re: trimming a string