How to enter a space in a search string?

Probably a very newbie question. How can I enter a search string in the standard search box that contains a space? I have tried:

'word1 word2'
"word1 word2"
word1\ word2

without any result. The tiddler in the docs (’ Searching in TiddlyWiki’) gives no way to do this either.

2 Likes

The standard search is by definition a word search. If instead you want to search for a phrase which includes more than one word eg “word1 word2” and your space, you will need to build a custom search and or use the various regular expressions.

I am sure others have wanted this before so lets see what other have to say.

Yes, sir. I have a custom search tab called Phrase to address literal searches. I have thought of converting/rewriting the phrase search to a “mixed” search. To do so, I thought of writing a separate search operator called mixedsearch or msearch. However, that is not the best solution. The better solution, from my point of view, is for the existing search operator to have a new flag… “mixed”, so we can do this…

[search:title,caption,text:mixed[my words some "in quotes" other not]]

To do this today I’d need to write it this like:

[search:title,caption,text[my words some other not]search:title,caption,text:literal[in quotes]]

And, aside, ‘mixed’ should be the default, not ‘word’.

Without the ‘mixed’ flag I might just write the msearch. :slight_smile:

@clsturgeon the literal search mode is the answer!

Users may also sometimes want to switch between some/word and literal (or your variation) so it would be great if we had a search option for the standard sort. In this selection dropdown we could include a virtual search you call mixed.

  • But It would also be nice if we could add excludions as well. eg term -widget
  • This would make sence in the word search at least.
1 Like

Being a console/command nerd, it would be cool to see the standard search expanded (Either by default, or via plugins) to also be a place where various commands etc could be run (This is why the Masquerading macro got me so excited :slight_smile: ).

Especially in conjunction with the motion (VIM-like) plugin, because the “/” key gives the search box focus, so I could totally be a keyboard warrior. lol

1 Like

@baiguai could you elaborate? Perhaps even in a new Topic?

  • Because I am not sure how Masquerading macro vs Masquerading titles.

We can already paste a full tiddler title in the search and hit enter to open that tiddler, and someone made a plugin to also hit enter to create new tiddlers.

Yeah, let me gather my thoughts on that, so far the Masquerade has been doing everything I need. But yeah, a new thread would be good for that discussion.

The “search in fields” from @Mohammad has a “literal” option.

see: Advanced Search in Fields — search in fields … There may be an intro post somewhere here at talk. You can search for it here.

1 Like

You can also see for instance the search included in DelphesNotes.

For instance try to search for “mark ref” in the search box here:
https://delphes-notes.tiddlyhost.com/

BR,

Eskha

Thanks for these good suggestions!
My conclusion from your answers: there is currently no simple way for a user to enter a search string containing spaces in the standard search box. However, the Search in Fields plugin solves this problem effectively.
I think searching for a string with spaces should be accessible from the standard search box, if only because in the English language many simple concepts have spaces in them, like ‘hen house’. Maybe the Search in Fields plugin could be integrated with the standard search box. Another possibility could be to indicate ‘literal spaces’ f.i. with a backslash, as in

word1\ word2

@SjaakA The following may help. As I said I was willing to write a “mixed” search feature.

Import the attach json file, which incudes 2 tiddlers. One that generates a custom advanced search tab (as per @TW_Tones) suggested. The other is a JavaScript macro that will convert the user input into a filter that TW supports.

It supports quoted phrases alongside words that are not in quotes. As per @TW_Tones suggestion, it also supports words prefixed with a minus sign, which instructs the mixed search to include tiddlers that do not have this word. i.e. if the word exists do not include the tiddler in the search results.

If you want to use the minus sign with a phrase, include the minus sign inside the quotes:

“search this phrase” “-but not this phase”

For this to work, you need to save your project and reload it. DO NOT FORGET. It will not work until you do.

It will add a new tab “Mixed” (under the Standard tab).

In “The Memory Keeper” I see:

I can now remove my “Phrase” tab… which is redundant.

One more point… The title search results only search the title field for the results. “The Other” results searches all these fields “title,text,description,caption,date,photocaption” to fit my needs. Edit the mmsearch line (at the top) in $:/plugins/cls/mk/ui/MixedSearchResultList to change the field list to fit your needs. I guess I should make this configuration.

Hope this helps,

Craig
MixedAdvanceSearch.json (3.3 KB)

3 Likes

As @clsturgeon says, and I did, use a Custom search. This is the standard approach to this kind of search extension.

  • The Advanced search Standard tab also displays this custom searches as tabs.

Fantastic contribution Craig!

  • I seem to be getting all results in the Mixed tab on tiddlywiki.com, not limited by phrase. I will look into it further.
1 Like

I did that with Tampermonkey. I was really excited about when I completed it and saw it work. Now I never use it :roll_eyes: :blush:

Using regex in the regular search box without having to do complex acrobatics would be really useful. I’m not a “pro” TW user but I do use it every day and I am familiar with regex. I can do so much more with regex.

But my guess is TW runs on Javascript so it would have to be JS flavored regex.

Thanks to all the people who have helped me over the years. :slight_smile:

You can build a regex search to suit you it all depends if its importiant to you. It not likely to be needed by a general audience.

  • I think its standard regex but you need to interact with tiddlywiki issues.

@Craig, I imported your MixedAdvanceSearch.json and it works terrific, thanks! It does exactly what I wanted, and more.
I also imported the Search Fields plugin by @Mohammad, which is even more powerful, but still needs going to the Advanced Search for a literal search (i.e. with spaces). Thanks also!

Sjaak