Skip to content

Instantly share code, notes, and snippets.

@samrayner
Created April 8, 2014 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samrayner/10104277 to your computer and use it in GitHub Desktop.
Save samrayner/10104277 to your computer and use it in GitHub Desktop.
on trim(theseCharacters, someText)
-- default values (all whitespace)
if theseCharacters is true then set theseCharacters to {" ", tab, ASCII character 10, return, ASCII character 0}
repeat until first character of someText is not in theseCharacters
set someText to text 2 thru -1 of someText
end repeat
repeat until last character of someText is not in theseCharacters
set someText to text 1 thru -2 of someText
end repeat
return someText
end trim
@doekman
Copy link

doekman commented Jun 8, 2016

Code fails when calling with a non empty string trim(true, "") of non-string trim(true,123).

I fixed it in my fork, but no idea how to send a merge request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment