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 :-)
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"
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
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
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 :-)