From: Mirko
Subject: strip trailing blanks (do I really need cl-ppcre?)
Date: 
Message-ID: <0edc8490-4f14-4204-8222-b268e31881e7@e24g2000vbe.googlegroups.com>
Hi,

I came up with the following function.  But it uses the regular
expression library, and I am wondering if there is (actually I am sure
that there is)
a simpler way that can use just CL's functionality.

(defun strip-trailing-blanks (string)
  "Remove trailing blanks from strings such as `ab c   ' -> `ab c'"
  (multiple-value-bind (match meat)
      (cl-ppcre:scan-to-strings "(.*[^ ]) *" string)
    (elt meat 0)))

Thanks

Mirko

PS - no Ruby solutions please :-)

From: ······@corporate-world.lisp.de
Subject: Re: strip trailing blanks (do I really need cl-ppcre?)
Date: 
Message-ID: <756c7cb0-bb20-45dd-bc79-3694e40de1f2@s1g2000prg.googlegroups.com>
On 12 Dez., 04:49, Mirko <·············@gmail.com> wrote:
> Hi,
>
> I came up with the following function.  But it uses the regular
> expression library, and I am wondering if there is (actually I am sure
> that there is)
> a simpler way that can use just CL's functionality.
>
> (defun strip-trailing-blanks (string)
>   "Remove trailing blanks from strings such as `ab c   ' -> `ab c'"
>   (multiple-value-bind (match meat)
>       (cl-ppcre:scan-to-strings "(.*[^ ]) *" string)
>     (elt meat 0)))
>
> Thanks
>
> Mirko
>
> PS - no Ruby solutions please :-)

? (string-right-trim '(#\space) "foo bar  ")
"foo bar"
From: Mirko
Subject: Re: strip trailing blanks (do I really need cl-ppcre?)
Date: 
Message-ID: <6bd03192-314f-406b-8706-b1a77e075667@n2g2000vbl.googlegroups.com>
On Dec 11, 10:57 pm, ·······@corporate-world.lisp.de"
<······@corporate-world.lisp.de> wrote:
> On 12 Dez., 04:49, Mirko <·············@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I came up with the following function.  But it uses the regular
> > expression library, and I am wondering if there is (actually I am sure
> > that there is)
> > a simpler way that can use just CL's functionality.
>
> > (defun strip-trailing-blanks (string)
> >   "Remove trailing blanks from strings such as `ab c   ' -> `ab c'"
> >   (multiple-value-bind (match meat)
> >       (cl-ppcre:scan-to-strings "(.*[^ ]) *" string)
> >     (elt meat 0)))
>
> > Thanks
>
> > Mirko
>
> > PS - no Ruby solutions please :-)
>
> ? (string-right-trim '(#\space) "foo bar  ")
> "foo bar"

duh.

Thanks.

Mirko
From: Kenny
Subject: Re: strip trailing blanks (do I really need cl-ppcre?)
Date: 
Message-ID: <49420fc0$0$4896$607ed4bc@cv.net>
Mirko wrote:
> On Dec 11, 10:57 pm, ·······@corporate-world.lisp.de"
> <······@corporate-world.lisp.de> wrote:
> 
>>On 12 Dez., 04:49, Mirko <·············@gmail.com> wrote:
>>
>>
>>
>>
>>>Hi,
>>
>>>I came up with the following function.  But it uses the regular
>>>expression library, and I am wondering if there is (actually I am sure
>>>that there is)
>>>a simpler way that can use just CL's functionality.
>>
>>>(defun strip-trailing-blanks (string)
>>>  "Remove trailing blanks from strings such as `ab c   ' -> `ab c'"
>>>  (multiple-value-bind (match meat)
>>>      (cl-ppcre:scan-to-strings "(.*[^ ]) *" string)
>>>    (elt meat 0)))
>>
>>>Thanks
>>
>>>Mirko
>>
>>>PS - no Ruby solutions please :-)
>>
>>? (string-right-trim '(#\space) "foo bar  ")
>>"foo bar"
> 
> 
> duh.
> 
> Thanks.

You might want to wait for Costanza's metaclass-based solution.

hth,kzo
From: Mirko
Subject: Re: strip trailing blanks (do I really need cl-ppcre?)
Date: 
Message-ID: <cb1c2ebe-9403-4c07-bd04-9f986856b286@n2g2000vbl.googlegroups.com>
On Dec 12, 2:14 am, Kenny <·········@gmail.com> wrote:
> Mirko wrote:
> > On Dec 11, 10:57 pm, ·······@corporate-world.lisp.de"
> > <······@corporate-world.lisp.de> wrote:
>
> >>On 12 Dez., 04:49, Mirko <·············@gmail.com> wrote:
>
> >>>Hi,
>
> >>>I came up with the following function.  But it uses the regular
> >>>expression library, and I am wondering if there is (actually I am sure
> >>>that there is)
> >>>a simpler way that can use just CL's functionality.
>
> >>>(defun strip-trailing-blanks (string)
> >>>  "Remove trailing blanks from strings such as `ab c   ' -> `ab c'"
> >>>  (multiple-value-bind (match meat)
> >>>      (cl-ppcre:scan-to-strings "(.*[^ ]) *" string)
> >>>    (elt meat 0)))
>
> >>>Thanks
>
> >>>Mirko
>
> >>>PS - no Ruby solutions please :-)
>
> >>? (string-right-trim '(#\space) "foo bar  ")
> >>"foo bar"
>
> > duh.
>
> > Thanks.
>
> You might want to wait for Costanza's metaclass-based solution.
>
> hth,kzo

I already embarrassed myself by not checking out hyperspec first.  No
need to drag me into another fight :-)