Re: TID Find and replace
Re: TID Find and replace
- Subject: Re: TID Find and replace
- From: Arthur J Knapp <email@hidden>
- Date: Tue, 07 May 2002 15:33:14 -0400
>
Date: Tue, 07 May 2002 12:26:13 -0400
>
From: "Eric Phillips" <email@hidden>
>
Subject: TID Find and replace
>
... 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.
set str to "abc, 1; def, 23; ghi, 456" --> debugging string
set o to text item delimiters -- save tids
repeat with d in "0123456789"
(* A "contains" operation almost always speeds up tids-based
* processing:
*)
if (str contains ", " & d) then
set text item delimiters to ", " & d
set str to str's text items
set text item delimiters to tab & d
set str to "" & str
end if
end repeat
set text item delimiters to o --> restore tids
str --> "abc 1; def 23; ghi 456"
>
... 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"}
>
repeat with aString in srchStrings
>
set theText to textReplace(theText, (", " & aString), tab)
In the above line, you simply need to append the digit to the tab:
set theText to textReplace(theText, ", " & aString, tab & aString)
In other words, you want to do these replacements:
", 1" --> tab & "1"
", 2" --> tab & "2"
etc...
where as the line as written is simply replacing with a tab:
", 1" --> tab
", 2" --> tab
etc...
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www.natural-innovations.com/as/>
on error number -128
end try
}
_______________________________________________
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.