Re: Remove extra spaces from a string
Re: Remove extra spaces from a string
- Subject: Re: Remove extra spaces from a string
- From: Emmanuel <email@hidden>
- Date: Mon, 9 Jun 2003 23:09:18 +0200
At 8:01 PM -0400 08/06/03, James Cass wrote:
>
Forgive me if this was covered already. If you just want to remove extra spaces (or any repeating character, tab, etc) from a string, the "tr" terminal command works pretty good. Here's an example with gratuitous "display dialogs".
>
>
--
>
-------------------------------------------------------------------------------------------
>
set withspaces to "Extra spaces."
>
display dialog "Before: " & withspaces
>
set withoutspaces to do shell script ("echo " & withspaces & " | tr -s ' '")
>
display dialog "After: " & withoutspaces
>
--
>
-------------------------------------------------------------------------------------------
Since we mention "tr" we have to mention also that it works only on strings up to 64KB.
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.