need help with regex filter

154 views
Skip to first unread message

Dave

unread,
Oct 30, 2018, 5:17:42 PM10/30/18
to TiddlyWiki
Hi,

I want to create a sort of "agenda" system by listing tiddlers that have the text ";;2018-10-30" or similar in them.

This kind of works:
<$set name="digit-pattern" value=";;[0-9]{4}-[0-9]{2}-[0-9]{2}">
<<list-links "[regexp:text<digit-pattern>]">>
</$set>



It lists out the tiddlers by title as links

What I can't figure out is how to convert that into a 
<$list filter="[all[current][regexp:text<digit-pattern>]sort[(regex finding)]limit[20]]">

version because I'd like to have the list sorted by date, not tiddler title, and I want to actually see the dates besides the links to the tiddlers as well.


Any suggestions?
thanks,
- Dave





Dave

unread,
Nov 3, 2018, 3:03:44 AM11/3/18
to TiddlyWiki
Ok, I have this other method going (not list-links)
<$set name="digit-pattern" value=";;[0-9]{4}-[0-9]{2}-[0-9]{2}">
<$list filter="[regexp:text<digit-pattern>]" variable="mydates">

<
<mydates>>
</$list></$set>

but I was expecting that this would list all the dates found, but it just lists the tiddler titles that have those dates.


Does anyone know how to return the actual dates found and not just the tiddler titles? (preferrably both, but one step at a time :)

TonyM

unread,
Nov 3, 2018, 3:12:45 AM11/3/18
to TiddlyWiki
Dave,

With all due respect, I advised you and others to move away from list-links macro to the <$list widget previously, it is much more customisable.

Just ask when you want more help because list and its filters is in my view the key to tiddlywiki.

Best wishes
Tony

TonyM

unread,
Nov 3, 2018, 3:33:46 AM11/3/18
to TiddlyWiki
Dave,

The dates are typicaly held in fields in each tiddler eg created and modified. If your list widget is not using the variable parameter, the currentTiddler is set for each title found in the filter (inside the list widget), so you can refer to the the field as follows {{!!created}} but this returns the actual content, a date serial number. You can use the view widget, format=date or format=relativedate to format the date/time fields how you want. With format=date you need to provide the template format, eg template="YYYY-0MM-0DD".


EG

<$list filter="that generates a list of tiddlers">
{{!!title}} <$view field=created format=date template="YYYY MMM"/> OR {{!!created}}
</$list>

For someone used to using list-links you may want to replace {{!!title}} with the link widget <$
link to={{!!title}} tooltip="Custom tooltip">{{!!title}}</$link>

Above typed from memory not rested.

Ps search for the date fields not a regex form of date with has[fieldname]]

Tony


Regards
Tony

Dave

unread,
Nov 3, 2018, 6:10:05 PM11/3/18
to TiddlyWiki
I'll tell you why I want this for context.

With the new Bob edition of TW5 that allows instances on Android and PC with tiddlers as files, I want to be able to (even when I don't have a node.js instance running - e.g. on a computer where the tiddlers folder has been shared  but I don't even have node installed) quickly create a text note ("some note.tid") that I want to have a due date associated with it.  I was wanting to just add the "tag" something like ;;2018-11-03 or ..2018-11-03 somewhere in the text (to be picked up later by the regex).

Having looked into it a bit, I see now that as long as I make a tid  file with at least a "title: some note" at the first line, I can put "due: 2018-11-03" on the  second line and it will automatically be picked up by the BobTW as a tiddler with a field called "due"


Just for interests sake however, I would like to know if it is possible to get a list displayed of text like ";;2018-11-03" simply by finding it with regex.

Mark S.

unread,
Nov 3, 2018, 7:31:45 PM11/3/18
to TiddlyWiki
There's no filter or widget that will currently split out the text that you find with a regular expression.

The PR #2963 I proposed would do that.

Jeremy has a concept for a <$match> widget that would find strings inside of strings. Unclear what the timeline for that is.

Another possibility might be to use the range filters and nested lists to generate all possible dates within a range. Then test for each possible date inside of the text, and, when found report the generated date and the tiddler that contained it.

If the dates inside the tiddler have a specific relationship to the text (e.g. Birthdates, appointment dates) then perhaps those dates should go into their own fields, which would make it unnecessary to do a regular expression process on the entire text. My understanding is that regular expressions are processor-heavy (though that makes more difference on a tablet then on a desk-top).

-- Mark

TonyM

unread,
Nov 3, 2018, 7:39:54 PM11/3/18
to TiddlyWiki
Dave,

Fyi

If you create a field in a text file to become a tiddler, and rather than use yyyy-mm-dd you enter a date of format yyyy0mm0dd where zero means leading zero below 9. The resulting field can be formatted to a date with the view widget, the you can determin day of week, month of year etc...

Regards
Tony

TonyM

unread,
Nov 3, 2018, 7:44:09 PM11/3/18
to TiddlyWiki
In a recent reply of mine I proposed a toolbar button to excise text and references to a field in the current tiddler, perhaps not for daves text tiddlers, but goes a long way to being able to reference snipitt

Regards
Tony

Dave

unread,
Nov 3, 2018, 11:29:58 PM11/3/18
to TiddlyWiki
 Thanks Mark, I think I'll abandon that line of usage


Tony, that's useful about the date format.  Thats probably why I was having trouble using the "days" operator.  I was about to post a separate question on that, but I'll try changing my date format first :)
Reply all
Reply to author
Forward
0 new messages