When using specific regexp the filter is working in macro but no in 'Advanced Search'. Why?

Hi,

I’m surprised by the fact that filter with specific regex content does not work the same way in my macro & in the ‘Advanced Search/Filter’ tool.

I explain
The following filter works fine in both places

[search:tags[Advisory / project-1]regexp:task_comment[MEA]regexp:task_date[2023-09-0]sort[task_date]reverse[]] 

But the filter

[search:tags[Advisory / project-1]regexp:task_comment[MEA]regexp:task_date[2023-09-(0[4-5])]sort[task_date]reverse[]] 

returns me tiddlers when used in a macro, but returns no tiddler when applied in the filter of the ‘advanced search’

The different is only the usage of regexp with [ ] to specify a range of digits [4-5]

Any idea why this is not working properly in the advanced Search ?

Regards

I’m sort of surprised that it works with the macro. I guess it works there because it’s being passed as a string.

Per the documentation of the regexp Operator,

The filter syntax makes it impossible to directly specify a regular expression that contains square brackets. The solution is to store the expression in a variable. See the examples.

Basically, if you define your regular expression globally (in a tiddler marked as $:/tags/Macro ) :

\define myreg() 2023-09-(0[4-5])

then you can reference it in your filter:

...regexp:task_date<myreg>...

or something like that …

1 Like

Hi,
Thanks a lot for your answer & details.
As a consequence I looked at different javascript macro that I’ve developped & where I use the $tw.wiki.filterTiddlers()
I noticed also that this tw javascript method does not support the regex with square bracket neither. Do you have an idea how I could, in my javascript macro workaround this problem ?
In my javascript I’ve tried to use ‘’ before the ‘[’ like 2023-09-(0\[4-5\]) but no succes (even with ‘\’ …)

Thanks for your help

Regards

Hi all,

I think it would be useful to include an input field in the AdvancedSearch where you can set the “regexp” variable

So you could use the variable in the search string like

[all[tiddlers]] :filter[get[created]format:date[YYYY-0MM-0DD]regexp<regexp>]

What do you think?

1 Like

Try importing these three test tiddlers into a test wiki

$___btc-test-styles.tid (161 Bytes)
$__core_macros_keyboard-driven-input.tid (4.9 KB)
$__core_ui_AdvancedSearch_Filter.tid (3.5 KB)

Sorry, there’s a small typo

$__core_ui_AdvancedSearch_Filter.tid (3.5 KB)

Import this tiddler instead of the above one

1 Like