trimming ?
Ken Ray
kray at sonsothunder.com
Tue Aug 20 14:18:01 EDT 2002
Don't forget about regular expressions... with them, you can do it in one
go:
function trimText pText
local returnVal
get matchText(pText,"^ *([^ ].*[^ ]) *$",returnVal)
return returnVal
end trimText
Have fun!
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
----- Original Message -----
From: "J. Landman Gay" <jacque at hyperactivesw.com>
To: <use-revolution at lists.runrev.com>
Sent: Tuesday, August 20, 2002 12:16 PM
Subject: Re: trimming ?
> Dave Cragg <dcragg at lacscentre.co.uk> wrote:
> >
> > At 12:03 pm +0200 20/8/02, Sylvain Le Gourriérec wrote:
> >>how can I trim spaces of a textfield, i.e. convert any " my text "
> >>into "my text"?
> >>
> >>Does a function exist or do I need to build one?
> >
> > You need to build one.
> >
> > 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
>
>
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list