• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reduce multiple characters to single occurrence (via do shell script?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reduce multiple characters to single occurrence (via do shell script?)


  • Subject: Reduce multiple characters to single occurrence (via do shell script?)
  • From: Joseph Weaks <email@hidden>
  • Date: Fri, 25 Mar 2005 01:15:43 -0600

I want to clean up a string by reducing all double, triple, etc. spaces to a single space.
I know how to do it with text item delimiters with something like:


set theString to "This has  extra spaces.
   I want them  removed."

repeat
if theString contains "  " then
	set Applescript's text item delimiters to "  "
	set theString to text items of theString
	set Applescript's text item delimiters to " "
	set theString to theString as string
else
	exit repeat
end if
end repeat

But, would a do shell script method be faster? Isn't there a one-liner perl command that would reduce multiple occurrences of a character to a single occurrence?

TIA,
Joe Weaks

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Reduce multiple characters to single occurrence (via do shell script?)
      • From: Christopher Stone <email@hidden>
    • Re: Reduce multiple characters to single occurrence (via do shell script?)
      • From: Gnarlodious <email@hidden>
  • Prev by Date: Re: Get download folder
  • Next by Date: Re: Reduce multiple characters to single occurrence (via do shell script?)
  • Previous by thread: Re: Modification date checker
  • Next by thread: Re: Reduce multiple characters to single occurrence (via do shell script?)
  • Index(es):
    • Date
    • Thread