Can you call a handler twice?
The first time I want to remove nbsp; from the text
the second time I want to change “Next” to “Listen!”
also, how do you get the text back from the call
set newtext to searchReplace() gives an improper handling error
set newtext to item 1 of searchReplace() also gives an error
what is the proper way to get the results from the handler?
searchReplace(clean_text, "nbsp;", "")
searchReplace(thisText, "Next", "Listen!")
to searchReplace(thisText, searchTerm, replacement)
set AppleScript's text item delimiters to searchTerm
set thisText to thisText's text items
set AppleScript's text item delimiters to replacement
set thisText to "" & thisText
set AppleScript's text item delimiters to {""}
return thisText
end searchReplace