Hello
I am trying to make a simple applescript that will remove the text “search for” from a variable
This is what I have:
set searchTerm to "search for script"
if searchTerm contains "search for" then
find "search for" and replace with "" ----->this is the part I need help with
end if
Any help will be greatly appreciated 
Hi,
this is the classical purpose for text item delimiters
set searchTerm to "search for script"
if searchTerm contains "search for" then
set theResult to searchAndReplace(searchTerm, "search for", "")
end if
on searchAndReplace(theText, findString, replaceString)
set {TID, text item delimiters} to {text item delimiters, findString}
set theText to text items of theText
set text item delimiters to replaceString
set theText to theText as text
set text item delimiters to TID
return theText
end searchAndReplace
Thank You! It works perfectly. 