How can I search for exact hyphenated text?

The description of DEVONthink’s search operators (p. 223 in the DEVONthink manual) explains the handling of hyphenated expressions:

Words separated by hyphens are handled like word1 word2 OR "word1 word2"

I’m trying to find all documents where I’ve used a code block with language-applescript, and it’s returning false positives like documents containing text such as “blah blah blah languge, AppleScript, blah blah blah”.

Is there any clever way to search for literal hyphenated expressions?

This works as expected…

I’ll check the docs.

Yes, the search will find language-applescript. What I’m saying is that it will also find other documents in which “language” is followed by “applescript”, without a hyphen.

No, there is no specific way to filter for that as hyphens aren’t indexed.

1 Like


I haven’t had time to try this as thoroughly as I’d wish before posting but @cgrunenberg recently posted a script which I’ve used successfully to search markdown files for markdown codes. It seems to work as you wish so, in some haste, I’m posting it here in case it helps you:

tell application id "DNtp"
			set search_string to display name editor "Markdown Search" info "Enter text to find:"
			if search_string is not "" then exit repeat
		end repeat
		set search results of viewer window 1 to (contents of current database whose type is markdown and plain text contains search_string)
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

Apologies if it doesn’t work but I’m in a bit of a rush at the moment!


1 Like

As noted in the Help > Documentation > Windows > Main Window > Search Pane

Thanks, but Inspection of that code shows it only searches for Markdown documents; it wouldn’t distinguish between a Markdown document containing a code block and one that didn’t. Hold on, the part about plain text contains ... actually makes a difference. That does find language-applescript and does not include other results, unlike using “contains” in the direct search interface (for lack of a better way to say it). I can make use of this.