• 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
Search and Replace in String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Search and Replace in String


  • Subject: Search and Replace in String
  • From: André Renault <email@hidden>
  • Date: Sat, 17 Jul 2010 14:58:54 +0200

Hey y'all
I discovered a hack to search and replace inside a string. It involves using text item delimiters to do the job.
 
on searchAndReplace(strToLookIn, searchStr, replaceStr)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to searchStr
set strToLookIn to every text item of strToLookIn
set AppleScript's text item delimiters to replaceStr
set strToLookIn to strToLookIn as string
set AppleScript's text item delimiters to tid
return strToLookIn
end searchAndReplace

André Renault
email@hidden
email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Search and Replace in String
      • From: Jon Pugh <email@hidden>
  • Prev by Date: Re: Rant Generator
  • Next by Date: Re: Rant Generator
  • Previous by thread: Re: Script time out
  • Next by thread: Re: Search and Replace in String
  • Index(es):
    • Date
    • Thread