From: Dimiter "malkia" Stanev
Subject: Re: trim a string
Date: 
Message-ID: <6ge69vFf9s23U1@mid.individual.net>
Francogrex wrote:
> This below seems trivial but before I lose my mind figuring this out
> (been stuck on it for 3 hours probably a sign of a low IQ). I want to
> trim the last two letters in a string str below
> 
> (setf str "ADGRFAG")
> 
> I tried to write the following procedure
> 
> (let ((temp (remove (nth (1- (length str)) (coerce str 'list)) str)))
>   (remove (nth (1- (length temp)) (coerce temp 'list)) temp))
> 
> OUTPUT -> "DRF"
> 
> But it's bad because it doesn't limit itself to the last two
> characters but removes everything inside that is similar to them? How
> can I trim just the two last chars? Thanks

(setf str (subseq "ADGFRAG" 0 (- (length "ADGFRAG") 2)))