trimming ?
Dave Cragg
dcragg at lacscentre.co.uk
Wed Aug 21 09:30:00 EDT 2002
At 6:49 am -0700 21/8/02, Rob Cozens wrote:
>>>This is what I use:
>>>
>>>function trimText pText
>>> put cr & tab & space into tTrimChars
>>> repeat while char 1 of pText is in tTrimChars
>>> delete char 1 of pText
>>> end repeat
>>> repeat while char -1 of pText is in tTrimChars
>>> delete char -1 of pText
>>> end repeat
>>> return pText
>>>end trimText
>>
>>Another variation I use:
>>
>>function trim theText
>> repeat for each word w in theText
>> put w & space after temp
>> end repeat
>> delete last char of temp
>> return temp
>>end trim
>
>Dave, Jacque, et al:
>
>If you're simultaneously stripping leading AND trailing spaces on a
>single line of text, can't you just use "get word 1 to -1 of
>theText"?
Nice one!
I guess I'm ruled by habit. However, by having a line such as:
put cr & tab & space into tTrimChars
it's very easy to modify behavior or create new functions, for
example if you want to trim out other leading and trailing
characters. (I'm a copy and paste person.)
Cheers
Dave
More information about the use-livecode
mailing list