Re: Whitespaces
- Posted by jiri babor <jbabor at PARADISE.NET.NZ> Dec 14, 2000
- 426 views
Brian, If whitespace consists of spaces only, then Derek suggestion is ok. If it includes tabs, carriage returns and linefeeds, you will need something like the function below. jiri function rtrim(sequence s) -- discard trailing whitespace of sequence s integer i i = length(s) while i do if not find(s[i], {9,10,13,32}) then exit end if i-=1 end while return s[1..i] end function ----- Original Message ----- From: "Derek Parnell" <derekp at SOLACE.COM.AU> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Thursday, December 14, 2000 5:46 PM Subject: Re: Whitespaces > Hi Brian, > > >What's the easiest way to get rid of whitespaces at the end of a string of > >text? > try this... > > -------------- > sequence text > for i = length(text) to 1 by -1 do > if text[i] != ' ' then > text = text[1 .. i] > exit > end if > > if i = 1 then > text = "" > exit > end if > end for > ------------- > > ----- > cheers, > Derek Parnell >