Find won't find comma quote in script

I’m trying to debug a script that works with comma-delimited text files. I’ve got a replacement string that removes a comma in the wrong place and I’m trying to locate it. So I do a find for:

,"

in the script. It only finds the second ," in most of these lines.

It seems to depend on the indentation of the previous line?

What’s going on here?

Pasting the same text in Text Wranger or Script Editor, the find works for every instance.

	replaceMyText(",(S),", ",,")
		replaceMyText(" - SP,", ",")
		replaceMyText(" SP,", ",")
		replaceMyText("- SP,", ",")
		replaceMyText("-SP (", " (")
		replaceMyText(" SP ", " ")
	replaceMyText(",(S),", ",,")
	replaceMyText(" - SP,", ",")
	replaceMyText(" SP,", ",")
	replaceMyText("- SP,", ",")
replaceMyText("-SP (", " (")
	replaceMyText(" SP ", " ")
	replaceMyText(",(S),", ",,")
		replaceMyText(" - SP,", ",")
		replaceMyText(" SP,", ",")
		replaceMyText("- SP,", ",")
		replaceMyText("-SP (", " (")
		replaceMyText(" SP ", " ")

I can’t reproduce the problem here. Anyone else?

Made a movie to illustrated this, then watching the movie I figured it out.

I have whole words x’d. In the sample provided it found

),"

but didn’t find

SP,"

Unchecking that worked.

Ed,

It’s hard to tell without having a sample of the text being searched and see how replaceMyText is written. Searching comma separated text can be a tricky thing. I would probably turn it into return separated, search and replaced and turn it back to comma separated.

In the same “search and replace” I included in this post you can see how I very easily change from the old text item delimiter to another one. That’s how the search and replace works, by changing that.

I have a search and replaces I’ve used for ever which works for everything I’ve thrown at it for many years. Maybe this will work for you.

on SeachAndReplace(SearchStr, ReplaceStr, TheStr)
	set OldASDelimiters to text item delimiters of AppleScript
	set text item delimiters of AppleScript to {SearchStr as string}
	set TheList to text items of TheStr
	set text item delimiters of AppleScript to {ReplaceStr as string}
	set TheNewStr to TheList as string
	set text item delimiters of AppleScript to OldASDelimiters
	return TheNewStr
end SeachAndReplace

Bill

Thanks Bill, But there’s no issue here. I thought it was a SD problem doing a find for ," inside the text of a script. Instead it was just the x for “Whole Words” in the SD search panel was checked that explained everything.

FYI, you handler is remarkably similar to the one I’ve been using for years.