Splitregexp at : but not at $:

54 views
Skip to first unread message

Mat

unread,
Apr 8, 2021, 6:35:49 AM4/8/21
to TiddlyWiki
I hope to improve HackSearch with a search field so that users can add custom "search terms" in a dictionary to find tiddler titles that are used as dictionary indexes e.g like so:

$:/core/UI/ViewTemplate/body : body text [[main field]]

I.e searching for, say, "text" returns that system title.

I have it working for non-system titles but one of the filter ops used is splitbefore[:] to split out the dictionary index in the entry row, but this doesn't work when the index is a system title because of the colon in $:/...

So I need a splitregexp that only accepts : but not $:

Any help is welcome.

Thank you.

<:-)

Saq Imtiaz

unread,
Apr 8, 2021, 6:51:56 AM4/8/21
to TiddlyWiki
Try this:
(?<!\$):

On my phone so this is untested.

Mat

unread,
Apr 8, 2021, 2:37:45 PM4/8/21
to TiddlyWiki
@Saq, much appreciated. Your filter is good but/and thanks to it I realized I need a "splitbeforeregexp". The idea is to use it to extract things in a dictionary so I circumvented the "$:/" issue by instead searching for colon+space. This is less than optimal because users might not stick to that when they type in an entry... but it's good enough.

Here's the result for anyone curious. Soon to be included in an updated HackSearch:

\define search-inner()
<$vars hasterm="""[enlist-input[]match[$(searchterm)$]]""">
   <$list filter="""[[dic]get[text]splitregexp[\n]prefix<candidate>filter<hasterm>then<candidate>]""">

   </$list>
</$vars>
\end

<$vars searchterm={{searchterm}} >
   <$list filter="""[[dic]get[text]splitregexp[\n]regexp<searchterm>splitbefore[: ]removesuffix[: ]]""" variable=candidate>
      <<hacksearch-inner>>
   </$list>
</$vars>

<:-)
Reply all
Reply to author
Forward
0 new messages