MacNN Forums (
-   Classic Macs and Mac OS (
-   -   Apple Script replace ( Aug 3, 2001 09:20 AM
Apple Script replace
I got a quck AppleScript question for anyone with an aswer

I have a script in which the variable may contain a space " " such as "dog and cat"

How would I go about having the script read the data and replace it with another character(s) such as "dog$and$cat"?

Anyone know?
acur128 Aug 3, 2001 09:55 AM
probably the easiest way would be to use delimiters to mark the space characters & replace them with "$" characters...
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>set thedata to <font color = red>"dog and cat"</font>
set the text item delimiters to <font color = red>" "</font>
set datalist to text items of thedata as list
set the text item delimiters to <font color = red>"$"</font>
set thenewdata to datalist as string
-- <font color = red>"dog$and$cat"</font>
set the text item delimiters to <font color = red>""</font></font>[/code]
this would just create a list of the individual characters in the string & replace all the " "'s with "$"'s, then convert the list back to a string (thenewdata).
All times are GMT -4. The time now is 12:17 AM.

Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

Content Relevant URLs by vBSEO 3.3.2