• 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
TID Find and replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TID Find and replace


  • Subject: TID Find and replace
  • From: "Eric Phillips" <email@hidden>
  • Date: Tue, 07 May 2002 12:26:13 -0400

Some very nice person on this list helped me with a find and replace scheme without having to open the document in a text editor, I am sorry I do not remember who that was. What I needed it to do was find ', #' where # is a number upto three digits, I want to change it to 'TAB#' where I get all the digits back in the number. What is happening is the search finds ', 1' which is part of ', 123, and it returns 'TAB23' I need 'TAB123'. Is there a way to do this with TIDs or do I need a different scheme? Any suggestions?

property srchStrings: {"1","2","3","4","5","6","7","8","9"}
set thefile to (choose file)
set fileID to (open for access thefile)
thry
set theText to read fileID
close access fileID
onerror m number n
try
close access fileID
end try
error m number n
end try
repeat with aString in srchStrings
set theText to textReplace(theText, (", "& aString), tab)
end repeat


on testReplace(theText, srchString, replString)
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {srchString}}
try
set {textList, AppleScript's text item delimiters} to {(text items of theText), {replString}}
set {newText, AppleScript's text item delimiters} to {(textList as text), od}
return item 1 of result
on error errMsg number errNbr
set AppleScript's text item delimiters to od
error errMsg number errNbr
end try
end textReplace
_______________________________________________
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.

  • Prev by Date: Re: disappointed with URL Access Scripting
  • Next by Date: Re: AppleScript 1.8.2b4 for Mac OS X Release Notes
  • Previous by thread: Re: AppleScript 1.8.2b4 for Mac OS X Release Notes
  • Next by thread: Re: TID Find and replace
  • Index(es):
    • Date
    • Thread