find tiddlers with field name using regex?

76 views
Skip to first unread message

Dave Parker

unread,
Apr 29, 2020, 8:24:58 PM4/29/20
to tiddl...@googlegroups.com
Hi,

I'm trying to list tiddler with a date as a field name.  In the following 3 lists, the first and the third work, but not the 2nd (which is the one I need to work)
<<list-links "[has[2020-04-29]]">>

----
<$set name="digit-pattern" value="[20][1-9][0-9]-[0-2][0-9]-[0-3][0-9]">
<<list-links "[regexp:has<digit-pattern>]">>
</$set>

----
<$set name="digit-pattern" value="[20][1-9][0-9]-[0-2][0-9]-[0-3][0-9]">
<<list-links "[regexp:title<digit-pattern>]">>
</$set>

The first finds tiddlers with "2020-04-29" as the field name, the third finds tiddlers with the title of the regex pattern, but I need to find tiddlers with field names by that pattern.

Why does the 2nd not work (and how do I fix it?)


Thanks,
- Dave

p.s., I also tried this which didn't work:
<$set name="digit-pattern" value="[20][1-9][0-9]-[0-2][0-9]-[0-3][0-9]">
<<list-links "[regexp:field<digit-pattern>]">>
</$set>


Mark S.

unread,
Apr 29, 2020, 8:59:05 PM4/29/20
to TiddlyWiki

Unless you've created a field "has", regexp:has won't mean anything.

I'm not convinced that #1 and #3 are doing what you think they're doing. [20] is a character class, not a match. I think they should be plain old "20" without the square braces. But I could be wrong.

Dave Parker

unread,
Apr 29, 2020, 11:39:57 PM4/29/20
to TiddlyWiki
oh yeah, that makes sense

tried this:
<$set name="digit-pattern" value="20[1-9][0-9]-[0-2][0-9]-[0-3][0-9]">
<<list-links "[regexp:has<digit-pattern>]">>
</$set>

but although it works in the 3rd one, the above still doesn't work.


Regarding the "has" argument, doesn't that mean in a filter you're looking for tiddlers that "have" a certain named field?  For example in the filter box on advanced search if I put in [has[2020-04-29]] it does return the correct tiddlers




Mark S.

unread,
Apr 30, 2020, 12:22:02 AM4/30/20
to TiddlyWiki
"Has" by itself is a filter operator. "Has" after a colon (:) is a suffix indicating a field. So regexp:has means to look in field "has" using a regular expression for comparison . It would probably be a bad thing to call a field "has", BTW IMO.

I'm not sure what you are trying to do in #2 that is different from #3. You're just checking to see if the title matches the pattern, right?

Dave Parker

unread,
Apr 30, 2020, 1:00:27 AM4/30/20
to TiddlyWiki
I'm trying to find field names that are named in a date format, .e.g.

Find tiddler "Howard" that has a field named "2020-04-28” or any date after this January 1, in fact every tiddler with a field so named.

tony

unread,
Apr 30, 2020, 1:21:57 AM4/30/20
to TiddlyWiki
Hi 

I'm learning too and found Eric Shulman's http://tiddlytools.com/filtergenerators.html is helping to learn all about this filtering business

This filter expression in filter search
[all[tiddlers]search:*:regexp[\d\d\d\d-\d\d-\d\d]sort[title]]

found a test tiddler 
Title: Howard
Field name: 2020-04-29
Field value: foo

Not sure why the field name would be named as a key, but you can try playing with different values in the PowerSearch  and copypasta the resulting query into the AdvancedSearch filter tab field

Best,
tony

Dave Parker

unread,
Apr 30, 2020, 2:16:21 AM4/30/20
to TiddlyWiki
Oh cool! I'll give that a try. I'm wondering if it would also find dates in titles and tags also though. I'll look there in the morning and see if I can restrict it to fields only.

Thanks!
- Dave

Dave Parker

unread,
May 1, 2020, 12:06:28 AM5/1/20
to TiddlyWiki
You all convinced me it was dumb to use a field *name* alone as a variable, so I used the info above to switch to keeping the dates in a field called dates like this:

\define subj2(tag day)

''Current complaints''

<$set name="digit-pattern" value="$day$">
<$list filter="[regexp:dates<digit-pattern>]">
<div>
{{||clist.temp.mynow}}
</div>
</$list>
</$set>

Previous Complaints
<$set name="today1" value="$day$">
<$set name="digit-pattern" value="[\d\d\d\d-\d\d-\d\d]" >
<$list filter="[regexp:dates<digit-pattern>!regexp:dates<today1>]"><div>
{{||clist.temp.mynow}}
</div>
</$list>
</$set>
</$set>
\end

\define subj()
<$macrocall $name=subj2 tag=Subjective day={{my-now}} />
\end

<table>
<tr>
<td><<subj>></td>
<td> {{newSubjective}} </td>
</tr>
</table>


Reply all
Reply to author
Forward
0 new messages