Selecting text using REGEX

Alex Rice alex at mindlube.com
Fri Oct 17 01:43:14 EDT 2003


On Sunday, September 28, 2003, at 06:48  PM, Ken Ray wrote:

> Interesting... my regEx version of Trim was this:
>
> function Trim what
>   local tText
>   get matchText(what,"(?s)\s*(\S.*\S)\s*",tText)
>   return tText
> end Trim

Beware this function fails for single-character-with-whitespace strings 
like " s" and " 9 ". By changing the regex to "(?s)\s*(\S.*\S?)\s*" and 
checking the result of matchText(), we can make it safer. But it still 
was failing some of my tests- I can't remember which strings though.


Alex Rice <alex at mindlube.com> | Mindlube Software | http://mindlube.com

what a waste of thumbs that are opposable
to make machines that are disposable  -Ani DiFranco



More information about the Use-livecode mailing list