How to remove leading and trailing spaces from a string?

Jim Bufalini jim at visitrieve.com
Tue May 12 20:26:43 EDT 2009


Hi Sadu,

If it is just leading and trailing chars of the entire string of words or
items or..., you can use:

Put word 1 to -1 of tString into tString. 

If it's a string of items use item 1 to -1...

This removes spaces and other "non-word" chars before word 1 and after word
-1. And it's quick.

Aloha from Hawaii

Jim Bufalini

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-
> bounces at lists.runrev.com] On Behalf Of Sadhu Nadesan
> Sent: Tuesday, May 12, 2009 2:17 PM
> To: use-revolution at lists.runrev.com
> Subject: How to remove leading and trailing spaces from a string?
> 
> 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
> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list