Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to search for just one word in a title. (Read 1332 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to search for just one word in a title.

Hello

I am trying to search my library's titles and return results with only the requested exact word within that title.  For example, if I search for the word 'all', I just want a list of titles with that exact word in them - 'ALL or nothing', 'Love is ALL', 'Let's ALL chant' etc, but not - 'SALLy', 'Off the wALL', 'Cindy IncidentALLy' etc. I've tried enclosing the search word in single and double quotations, used the terms IS and HAS, without success.
Is there a way to do it please?

Thanks.


Re: How to search for just one word in a title.

Reply #2
I'm no expert on this, but this comes close:

Quote
%title% HAS " all "

Note the space before and after the word all.  Search expressions are not case-sensitive.

However, this would not capture titles ending with the word all like "I Want It All". The Query Syntax Help (click on ? at the right of the query bar) doesn't seem to have a solution for this, unless all capabilities are not documented in this Help page.


Edit: this post can be removed. I saw in grimes' reply * can be used which isn't mentioned in the Query Syntax Help


Re: How to search for just one word in a title.

Reply #4
Just for correctness, still needed a fourth case in case the title is just "all".
Code: [Select]
TITLE IS all OR TITLE IS all * OR TITLE IS * all * OR TITLE IS * all


 

Re: How to search for just one word in a title.

Reply #7
Undocumented, but question mark is a wildcard too, so this one will also return some more unwanted and wanted:

Clones (We're All)
Alle Gegen Alle
Austin & Ally Theme Song
Sick of It All!

... but will not find Uh! (Unholy Death upon You All!)

A precise query isn't worth it, I guess.

Re: How to search for just one word in a title.

Reply #8
"title HAS" uses no wildcards, so its possible to use:

Code: [Select]
title IS all OR title IS all * OR title IS * all * OR title IS * all OR title HAS  all? OR title HAS  all!

"title HAS  all)" is not working. Why?

Re: How to search for just one word in a title.

Reply #9
The query syntax gets ridiculous for some simple uses cases... regexp should be a must here, or at least simple and usable functions to split sentences by words, search for words, etc.

Anyway, theoretically you could run something like this XD
Code: [Select]
"$puts(s,mad)$puts(lt,$lower(%title%))$put(i,$strstr($get(lt),$get(s)))" GREATER 0 AND "$puts(s,mad)$puts(lt,$lower(%title%))$puts(i,$strstr($get(lt),$get(s)))$puts(len,$len($get(s)))$puts(len+1,$add($get(len),1))$puts(i-1,$sub($get(i),1))$puts(next,$substr($get(lt),$get(len+1),$get(len+1)))$puts(prev,$substr($get(lt),$get(i-1),$get(i+1)))$replace($get(next), ,x,?,x,¿,x,!,x,¡,x,x,a)" IS x
The 2 "puts" with s variable would need to be edited on every search with the appropriate word.

Essentially looks for a word and checks the next letter to it is an allowed char or a space (it should be extended for the previous letter case and also the when the title is just the searched word). The list of allowed chars should be expanded with parentheses, [], etc.

Cons: it's stupidly complex AND values within a put clause can not be used on the next clause, so there is a lof of code duplication. I don't really get why puts can not be added at the beginning and reused for the entire expression, it seems the expression is split into multiple expressions when evaluated and there is no global variable space.

Re: How to search for just one word in a title.

Reply #10
For the sake of the exercise:
Does anything simplify if we assume that a "word" has only ASCII letters, and use the $ascii function to strip away interrobangs and the like?

Re: How to search for just one word in a title.

Reply #11
New attempt:
Code: [Select]
title IS all OR "$replace(%title%,?, ,!, ,'', ,-, ,_, ,')', ,'(', ,'[', ,']', ,',', ,'.', ,':', ,';', )" IS all * OR "$replace(%title%,?, ,!, ,'', ,-, ,_, ,')', ,'(', ,'[', ,']', ,',', ,'.', ,':', ,';', )"  IS * all * OR "$replace(%title%,?, ,!, ,'', ,-, ,_, ,')', ,'(', ,'[', ,']', ,',', ,'.', ,':', ,';', )"  IS * all

Re: How to search for just one word in a title.

Reply #12
Not sure if you caught them all; but, when you have caught them all: you have caught them all.