How trim?

Alex Tweedly alex at tweedly.net
Sat Oct 22 10:02:24 EDT 2005


Bob Warren wrote:

> Sometimes inexperienced Rev programmers have to ask questions that 
> make them want to crawl under the table in shame because probably the 
> answer is idiotically simple. Here is such a question.
>
> If I have a string, say:-
>
> "   The cat sat under the mat   "
>
> - and I want to trim off the leading and following blanks to give:-
>
> "The cat sat on the mat"
>
put word 1 to -1 of myVar into mySecondVar

Trimming only one end is slightly harder - in fact, the best way I can 
think of is surprisingly complex
put char 1 to -2 of (word 1 to -1 of (t & "="))      -- could have been 
any non-space character
put char 2 to -1 of (word 1 to -1 of ("=" & t))      -- could have been 
any non-space character


Hopefully someone else will come up with an easier way, and I will slap 
my head in annoyance :-)

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.4/143 - Release Date: 19/10/2005




More information about the use-livecode mailing list