RegEx Replace Text -- strip leading and trailing spaces

Wouter wouter.abraham at scarlet.be
Wed Apr 13 15:25:43 EDT 2005


On 13 Apr 2005, at 18:09, Trevor DeVore wrote:

> On Apr 13, 2005, at 3:14 AM, Matt Denton wrote:
>
>> G'day all
>>
>> Regular Expression syntax in ReplaceText is driving me a bit loopy 
>> right now, I was hoping someone out there could work out what I'm 
>> doing wrong...
>>
>> I want a single RegEx expression using ReplaceText to strip out 
>> leading and tailing spaces, leaving any spaces in the middle 
>> untouched.
>
> Matt,
>
> I use this regex to strip whitespace:
>
> get replaceText(pString, "^[ \t\r\n]+|[ \t\r\n]+$", "")
>
>
> -- 
> Trevor DeVore
> Blue Mango Multimedia
> trevor at mangomultimedia.com

No offence, but this won't strip whitespaces at both ends of a string 
in one pass.
And it is about ten times slower for one pass than: get word 1 to -1 of 
pString
(which does strip leading and ending whitespaces in one pass, but true 
it is no regex).

Gr W.



More information about the use-livecode mailing list