Extract part of tiddler titles using regexp

I have tiddlers with title format - 05,June2023 , 10,April2023 and so on (format used is DD,MMMYYYY)
I want to use parts of this title within fields of a template tiddler displayed via a viewtemplate on the tiddlers 05,June2023 , 10,April2023
For this I want to extract the parts June2023 and 2023 from the title 05,June2023 and parts April2023 and 2023 from the title 05,April2023 and so on
What should be the regexp to be used for extracting these two parts of the title ?

I don’t think you need regexp for this: the split operator should do.

To return June2023: [<currentTiddler>split[,]rest[]]
To return 2023: [<currentTiddler>split[]last[4]join[]]

3 Likes

Consider saving new dates in another field in full tiddlywiki serial number so you don’t have to extract details from the title.

  • I have custom buttons that set the journal-data field when creating journals for this purpose. search/ask if you want them.
  • I have not yet started memorising regular expressions (yet), so I know every other method to parse a string and its fairly rarely I need to revert to regular expressions, but I still use a seperate date field.

Thank you @etardiff for helping out. I wrapped it inside triple curly brackets to get the extracted parts of the title.

{{{[<currentTiddler>split[,]rest[]]}}}

{{{[<currentTiddler>split[]last[4]join[]]}}}

@etardiff
anyway to get this extracted part of the title into the same tiddler’s fields like shown below.
month: June2023
I don’t want field to look like this - month:{{{[<currentTiddler>split[,]rest[]]}}}

Yes, but you’ll need an action widget and something to trigger it. Try this:

<$button>
Click to set month
<$action-setfield month={{{ [<currentTiddler>split[,]rest[]] }}} />
</$button>

You could also specify the field and desired field value by using the setField and setTo attributes of the button widget, or using the actions attribute to call an action widget defined in a macro. More on those options in the documentation, if you’re interested. (I chose to supply the action widget as content within the $button tags mostly for clarity and brevity.)

If you already have a button to generate new tiddlers with this title format, you could use it to set the month field when the tiddler is first created - see $action-createtiddler for more details.

2 Likes

@etardiff Thanks for the tip. I made to two new buttons to create custom day (journal) and month tiddlers in a single click without any need to type anything in the month and year fields. This is very useful.