How search for the string, the whole string and nothing but the string?

I have

myfield: foo bar baz

What should I use to ensure a search that gives true only if any of those strings in full is searched for?

I was expecting search:myfield:literal[] to do this but e.g oo returns true. (I guess I literally don’t understand literal!) so it seems TW can’t do this directly but, surely, what I’m after can’t be totally uncommon - !?

I’m guessing(!) a regex would have to accept either of these forms:
|xxx_     _xxx|     _xxx_    
i.e that the string is either a first or last in the field, or surrounded by whitespace) but I don’t know how to formulate such a regex.

Thanks!

literal here is talking about the search term, not the string being searched. So oo literally appears in there. I think you will need to resort to a regexp search. Assuming your text is simple (without regex special characters), you can do this by adding word boundary markers (\b) at the beginning and end.

[search:my-field:regexp[\boo\b]]

This matches oo ee oo aah aah but not foo bar baz.

.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions

But so what is one searching for if literal is not specified?

[search:my-field:regexp[\boo\b]]

Ah! that does seem to work. Thank you!

ting tang walla walla bing bang?

2 Likes

Yeah, thanks… in my previous experience, I seem to always do something wrong when attempting to apply externally found regexps in TW. I think they need some syntax massaging to work in TW or something.

Creezus Jist!… that was some annoying song! :sweat_smile:

Exactly. But I didn’t want to link to the song, in solidarity with my fellow ear-worm sufferers. So thanks a lot, Shulman! :wink:

… resisting the urge to click on that song… resisting the urge… resisting the urge… resisting… oh, hell with it!

I think that’s the default, although the docs don’t specify that.

They rarely need massaging, but they often can’t be used as filter literals, since important regexp characters conflict with filter syntax characters. But it’s easy to fix that with let, set, define, procedure, and such:

<$let re = "[\boo]b]">
{{{ [all[tiddlers]search:my-field:regexp<re>] }}}
</$let>
1 Like

Looks like schoolyard humor \boo\b

.1313: Regex Golf - explain xkcd

.1638: Backslashes - explain xkcd

backslashes

hear be dragons ( not *your specific case *(afaik:& ftr iv not checked;) but generally)

… iv heard haunting :ghost: tails of regexp
that would often end in blood curdling screams and inevitably gruesome (infrastructure) postmortem’s :skull:

a regex would

crash your fave q&a site :sweat:

.https://stackstatus.tumblr.com/post/147710624694/outage-postmortem-july-20-2016

who has not
crossed the gorge of eternal peril in search of the correct-regexp?

… i dont know that !
ahhhhhhh

where do you find them ?
are they from some other JavaScript source?

because :sob: https://stackoverflow.com/questions/2298007/why-are-there-so-many-different-regular-expression-dialects

stackoverflow.com/a/11857890/874188 has a bit of historical background if that’s what you are after. – tripleee

: D

2 Likes

For searching the regexps should be relative straight forward. Learning them IMO depends on the quality of the description. The best I could find is: https://www.regular-expressions.info/ I did learn everything I know about regexps from there.

The important thing is, that you do not read it. You have to work through the examples they give.

1 Like