RegEx not working in filter despite correct format

40 views
Skip to first unread message

MagoArcade

unread,
Jul 20, 2019, 6:34:32 PM7/20/19
to TiddlyWiki
Hi - having problems with variables in filters. The code below doesn't produce any results:

\define rx_TidID_RelType(Tid RelType)
"$Tid$".*"$RelType$"
\end
-------------

''All Sub-tasks of this tiddler''

<$set name=rxSearch value=<<rx_TidID_RelType {{!!tmap.id}} SubTaskOf>>>

rxSearchTerms
: <<rxSearch>>

<$list filter="[regexp:tmap.edges<rxSearch>]">

</$list>

However, it's producing the regex search correctly on examining the output:


All Sub-tasks of this tiddler

.*rxSearchTerms: "087aa75e-ec77-4cd2-a774-c41c0ee52382".*"SubTaskOf"



tmap.edges essentially holds an array, thus having to use regex. Here's a couple of examples of data from tmap.edges:

"a2373aa7-f71b-48e3-ac64-10e464c135a8":{"to":"087aa75e-ec77-4cd2-a774-c41c0ee52382","type":"SubTaskOf"
"a2373aa7-f71b-48e3-ac64-10e464c135a8":{"to":"087aa75e-ec77-4cd2-a774-c41c0ee52383","type":"SubTaskOf"

The RegEx search is resolved to something like this format:

.*"087aa75e-ec77-4cd2-a774-c41c0ee52382".*"SubTaskOf"

I know this works: regexr.com/4hqih

I also have it working filtering results at other points in my code:

<$list filter="[regexp:tmap.edges{!!tmap.id}]">


</$list>

this produces a list of all entries matching the current tiddler's tmap.id

Why isn't variable substitution working in this instance?

I chose to use a macro due to the complexities introduced into doing it inline with special characters (quotes in this instance) 

Any help[ much appreciated (I know I'm hitting these forums hard tonight, but just learning TiddlyWiki!)

Mark S.

unread,
Jul 20, 2019, 7:33:21 PM7/20/19
to TiddlyWiki
This sort of thing used to drive me nuts. Still does sometimes. It looks for all the world
like you have properly formed and even tested your string regular expression construction.
But you haven't because your macro is first getting passed to the value attribute, and THEN
being rendered. What you see on the screen is the rendered value, but not what value gets.

The solution is the WikifyWidget, that can render (wikify) the results of the macro the way
you mentally meant it to be. The results might look like what I've posted below.

Good luck!


\define rx_TidID_RelType(Tid RelType)
"$Tid$".*"$RelType$"
\end
-------------

''All Sub-tasks of this tiddler''

<$wikify name=rxSearch text="<<rx_TidID_RelType {{!!tmap.id}} SubTaskOf>>" >


rxSearchTerms
: <<rxSearch>>

<$list filter="[regexp:tmap.edges<rxSearch>]">

<
/$list>

</
$wikify>


MagoArcade

unread,
Jul 21, 2019, 3:15:24 AM7/21/19
to TiddlyWiki
That did the trick thanks. :)

Blimey - TiddlyWiki is proving quite a monster to code in. Not sure if it's me just not getting it or it's quite different to what I'm used to. Are there any good alternative guides to coding in tw? I find the official a bit lacking in detail (like this issue for instance)??

Of course - not dissing tw! I'm amazed by what it can do.
Reply all
Reply to author
Forward
0 new messages