How trim?

Buster wouter.abraham at scarlet.be
Sat Oct 22 17:17:34 EDT 2005


Hi,

It is indeed elegant, but a condition check is necessary here as it  
will remove the first word + the space(s) if there is no space at the  
start of the line.

> "        The cat sat on the mat.         "

will become

  " The cat sat on the mat.         "

But if no space in front the result is

"cat sat on the mat.         "


Greetings,
Wouter


On 22 Oct 2005, at 22:41, Bob Warren wrote:

> Well, I am relieved to say it wasn't such a dumb question after  
> all. Thanks chaps! And thanks particularly to Thomas Fischer who  
> has come up with the most elegant solution. QED. Now I need to go  
> off and study regular expressions.....
>
> Bob
> ------------------------------------------
> >This is a classical application of regular expressions. Try
>
> >get replaceText("        The cat sat on the mat.         ","^ *","")
>
> >The "^" tells the search engine to start at the beginning.
> >The "*" looks for as many of the previous characters (here space)  
> as >possible.
>
> >To get rid of them at the end use
>
> >get replaceText("        The cat sat on the mat.         "," *$","")
>
> >The "$" tells the search engine to look at the end.
>
> _______________________________________________
> 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