Another newbie question: search and replace in a string

I want to replace every instance of string A in string B with string C…

I have tried the following code but applescript always assumes that the “<” is not a part of the word to be replaced…

set blah to “///whatever”
set AppleScript’s text item delimiters to “/”
set every word of blah where it is “” to “HELLO”
display dialog blah

any ideas?

Thanks!
Ben

Ben,

work with text items of blah…

set blah to "/<show>/<shot>/whatever"
set AppleScript's text item delimiters to "/"
words of blah -->  {"<", "show", ">", "<", "shot", ">", "whatever"}
every text item of blah -->  {"", "<show>", "<shot>", "whatever"}

If I wasn’t at work and had time to work out the rest, I would :rolleyes:
I hope this gets you started.

Brad Bumgarner, CTA

Ben,

Me again. I’ve had a little time to work on this question some more. Here is what I came up with:

set blah to "/<show>/<start>/some text"
set AppleScript's text item delimiters to "/"
set blahItems to text items of blah
repeat with x in blahItems
	if contents of x = "<show>" then
		set contents of x to "hello"
	end if
end repeat
set AppleScript's text item delimiters to "/"
set blah to every item of blahItems as text
set AppleScript's text item delimiters to ""

It could probably be done more elegantly. Jon has done some text manipulation that blows me away :stuck_out_tongue:

Hope this helps,
Brad Bumgarner, CTA

Works exactly as advertised.

Thanks!

Ben