RegEx Replace Text -- strip leading and trailing spaces

Wouter wouter.abraham at scarlet.be
Wed Apr 13 16:26:41 EDT 2005


On 13 Apr 2005, at 21:47, Trevor DeVore wrote:

snip


>
> Is there a way to do ltrim (trim whitespace on left of string) in 
> plain transcript?  Right now I just use:
>
> function str_lTrim pString
> 	get replaceText(pString, "^[ \t\r\n]+", "")
> 	return it
> end str_lTrim
>
>
> -- 
> Trevor DeVore
> Blue Mango Multimedia
> trevor at mangomultimedia.com

In plain transcript one could do:

function str_lTrim pString
	return char 1 to -2 of word 1 to -1 of (it & "x")
end str_lTrim

But  it is about 2 times slower than the regex solution in this case.
So the choice is obvious :-)

Wouter



More information about the use-livecode mailing list