AW: AW: AW: How trim: Bug in RegExp engine

Thomas Fischer fischer at mail.sub.uni-goettingen.de
Fri Oct 28 10:30:00 EDT 2005


Hi Wouter,

you wrote

> These timing tests are not completely fair because:
> 
>    while char 1 of testString is space  ->  removes only space from  
> front if any
>      delete char 1 of testString
>    end repeat
> 
> word 1 to -1 of testString   -> removes tabs, spaces and returns from  
> front and back of string if any
> token 1 to -1 of testString  -> removes tabs, spaces, hard spaces,  
> and returns from front and back of string if any
> 
> You compare time it takes for frontal removal of space if any with  
> time it takes for frontal and back removal of tab and space if any or  
> tab, space and hard space (semicolon and return) if any.
> To make it more fair, the time testing handlers should be equalized  
> on the removal of tabs, spaces and hard spaces from front and back of  
> a string.
> 
> On the other hand this gives an indication of which way to use in  
> what case.

I only wanted to give some information to use for a decision in a script.
So if you just want to trim spaces or any of a bunch of characters from the front _or_ the end,

 "while char 1 of testString is space"
or
 "while char 1 of testString is in myCollection"
will do a good job and be crystal clear.
"Token" is surprisingly slow, and "word" is very effective if you can control the situation.

> word 1 to -1 of testString   -> removes tabs, spaces and returns from  

But do you know what you get if you ask for

get word 1 to -1 of quote & "    My test with lots of spaces at the end     "?

All the best
Thomas


--
Thomas Fischer
Salzburg 




More information about the use-livecode mailing list