Skip to content

Instantly share code, notes, and snippets.

@doekman
Forked from samrayner/trim.applescript
Last active July 7, 2019 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doekman/ee9e4651043c5b346f15a0ffbce21b94 to your computer and use it in GitHub Desktop.
Save doekman/ee9e4651043c5b346f15a0ffbce21b94 to your computer and use it in GitHub Desktop.
on trim(theseCharacters, someText)
if class of someText is text and length of someText > 0 then
-- 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
end if
return someText
end trim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment