Search operator: search for whole words only

54 views
Skip to first unread message

Hubert

unread,
Apr 29, 2020, 10:09:02 AM4/29/20
to TiddlyWiki
Hi,

I want to only find whole words when using the search Operator.

I've tried the options listed here but cannot make my filter expression match whole words only, even when using the literal flag for search strings.

For example, when the search string is TW I only want to find this:
  • TW info
  • Hints for tw linking

and NOT this:
  • Two little monkeys
I suspect that the whole word search can be achieved with regex, would anyone have any idea how?

Many thanks!
Hubert

Mark S.

unread,
Apr 29, 2020, 10:32:31 AM4/29/20
to TiddlyWiki
Something like:

[regexp:text[\bTW\b]]

Hubert

unread,
Apr 29, 2020, 10:52:26 AM4/29/20
to TiddlyWiki
Thanks Mark.

I still can't get it to work. Here's my entire filter expression. I know it's clearly incorrect but I can't find any other way to reconcile the different types of brackets with the title flag, the regex expression and the in-filter transclusion.

My search string to be matched is in the note field of the $:/note tiddler:

<$list filter="""[tag[note]regexp:title[\b{$:/note!!note}\b]]""">

</$list>

Thanks!
Hubert

Hubert

unread,
Apr 29, 2020, 11:25:10 AM4/29/20
to TiddlyWiki
OK, I had to resort to the $wikify widget but now it works:

<$wikify name="searchterm" text="""\b{{$:/note!!note}}\b""">
<$list filter="""[tag[note]search:title:regexp
<searchterm>]""">
<
<ListedNotes>>
</$list>
</$wikify>

Thanks again Mark for pointing me in the right direction!

Regards,
Hubert

Hubert

unread,
Apr 29, 2020, 12:47:00 PM4/29/20
to TiddlyWiki
For the record, \b appears limited to ASCII characters. It will not match non-English diacritics correctly, as explained in this post.

Regards,
Hubert
Reply all
Reply to author
Forward
0 new messages