How to remove leading and trailing spaces from a string?
Phil Davis
revdev at pdslabs.net
Tue May 12 20:26:57 EDT 2009
Seems like I remember Ken also suggesting another solution which even I
can understand:
function unpadded pText
return word 1 to -1 of pText -- Ken's solution
end unpadded
At least I *think* it was Mr. Ray....
Phil
Sadhu Nadesan wrote:
> Howzit,
>
> I needed to do that and was about to (once again) reinvent the wheel,
> but decided to use the Rev search engine instead, and came across this
> handy regular expression function from Ken Ray, posted circa 2006.
> Works great! Thank you, Mr. Ray.
>
> Sadhu
>
> function trimWS pText
> -- Remove all leading and trailing whitespace characters.
> -- I.E., space, tab, carriage return, line feed, form feed.
>
> return replaceText(pText,"(^\s+)|(\s+$)",empty)
>
> end trimWS
--
Phil Davis
PDS Labs
Professional Software Development
http://pdslabs.net
More information about the use-livecode
mailing list