string cleaning

Alex Rice alex at mindlube.com
Tue Nov 11 11:01:56 CST 2003


On Nov 10, 2003, at 5:35 PM, Rob Cozens wrote:

> Looks OK to me, Alex; but why not just use:
>
> function printableCharString pString
>  local tRes, c
>  repeat for each character c in pString
>    if c < space or c > "~" then next repeat
>    put c after tRes
>  end repeat
>  return tRes
> end printableCharString

Rob here is the same function, but 32% faster!

function printableCharString2 pString
   -- \xxx are octal character codes in regex
   -- keep octal \040 - \176 (space - "~")
   return replaceText(pString, "([\000-\037]|[\177-\777])+", empty)
end printableCharString2


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