Re: Find and replace space by the Terminal equivalent
Re: Find and replace space by the Terminal equivalent
- Subject: Re: Find and replace space by the Terminal equivalent
- From: Barry Wainwright <email@hidden>
- Date: Sun, 02 Oct 2005 04:02:58 -0700
- Thread-topic: Find and replace space by the Terminal equivalent
Title: Re: Find and replace space by the Terminal equivalent
On 2/10/05 02:47, "Jay Louvion" <email@hidden> wrote:
How would you do a find and replace in a string where you want to replace spaces (“ “) by the command line equivalent (regarding file system, at least : “\ ”) for some obvious reason, it doesn’t compile, but what’s the workaround ?
If you are trying to pass a text string to the shell command line, you can just use ‘quoted form of ...’:
quoted form of "this is a 'test' string"
-- "'this is a '\\''test'\\'' string'"
This will allow you to send commands such as:
set myString to “Hello World!”
do shell script “echo “& quoted form of myString
However, if this is not what you want, then the quickest way to accomplish your actual request is to use the TIDs:
Set myString to “Hello World!”
Set {oldTIDs, applescript’s text item delimiters} to { applescript’s text item delimiters, {“ “}}
Set myString to text items of myString
Set Applescript’s text item delimiters to {“\ “}
Set myString to Mystring as text
Set applescript’s text item delimiters to oldTIDs
--
Barry
_______________________________________________
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