• 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
Re: shell script and text manipulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script and text manipulation


  • Subject: Re: shell script and text manipulation
  • From: John Stewart <email@hidden>
  • Date: Wed, 23 Feb 2005 09:56:36 -0500

On 2/23/05 at 11:13 AM,  the entity Christian Vinaa spoke thusly

>finding (myWord)  and replacing with (myOtherWord)
>
>(just the jist of the script - not actually working)


This works but as written it will replace all instances of the searched for text within the body of the text being searched.

set txtStr to "some text to be searched"
set srchStr to "text"
set rplcStr to "words"

set newTxt to my doRplc(txtStr, srchStr, rplcStr)
--> "some words to be searched"

on doRplc(txtStr, srchStr, rplcStr)
    set {oldDelims, my text item delimiters} to {my text item delimiters, {srchStr}}
    set temp to every text item of txtStr
    set my text item delimiters to {rplcStr}
    set txtStr to temp as text
    set my text item delimiters to oldDelims
    return txtStr
end doRplc

JBS
--
 _______________________________________________
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

References: 
 >shell script and text manipulation (From: Christian Vinaa <email@hidden>)

  • Prev by Date: strange behavior.
  • Next by Date: Re: Aaaarrrggghhh XML!
  • Previous by thread: shell script and text manipulation
  • Next by thread: Re: shell script and text manipulation
  • Index(es):
    • Date
    • Thread