On Saturday, July 11, 2020 at 7:59:42 AM UTC-7, Guido B wrote:
>
> I use the following filter expression to list all tiddlers where the field 
> "musiker" contains the title of the current tiddler: 
>
>> <$set name=name value= {{!!title}}>
>> <<table-dynamic filter:"[regexp:musiker<name>]" fields:"title interpret 
>> year label stil">>
>> </$set>
>
>
> Problem: for a name like "Arca", it does not only list those tiddlers 
> containing "Arca", but also those containing "Arcade Fire". 
> Solution: I use a regex-pattern like (?<![\w\d])Arca(?![\w\d])
>
> Here's my question: how can I combine a variable name (in this case 
> <name>) with a regex-pattern in a filter expression?
>

Use a macro to construct the regexp pattern, like this:

\define pattern()  (?<![\w\d])$(name)$(?![\w\d])

<$vars name={{!!title}}>
<<table-dynamic filter:"[regexp:musiker<pattern>]" fields:"title interpret 
year label stil">>
</$vars>

Notes:
* I prefer to use the <$vars> widget rather than the older <$set> widget to 
get the title value into a variable
* The macro does a direct string replacement to insert the current value of 
the "name" variable into the regexp
* I think there was a missing "]" in your filter syntax.  I assume this was 
just a typo or copy/paste error.

Give it a try and let me know how it goes...

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a36ef753-911b-4e8e-b135-3fffda0bcde2o%40googlegroups.com.

Reply via email to