03-15-2021, 05:32 AM | #1 |
Junior Member
Posts: 8
Karma: 10
Join Date: Apr 2014
Device: Kobo Aura HD
|
Custom column from tags
I try to create a custom column that contains a date value from the tags column. The format of that tag is 'year-month-day' (where the month and day will be padded with 0 to length 2) eg. 2021-03-15.
I tried this function to get it but it's not working and i can't figure out why (could be the regex or i'm using the wrong function here or all those ' are canceling themselfs out somehow?): {:'list_re(field('tags'), ',' ,'\d{4}-\d{2}-\d{2}')'} Would be nice if someone could help me out with this one. The next problem will be to create a hierarchy from that date field: Year.Month.Day I know i could easily create an custom column with a hierarchy but i try to use the default columns and create automated custom columns from those. Thanks, Johan |
03-15-2021, 08:59 AM | #2 |
Grand Sorcerer
Posts: 11,942
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Use
Code:
program: list_re(field('tags'), ',', '\d{4}-\d{2}-\d{1}', '') |
Advert | |
|
03-15-2021, 12:31 PM | #3 |
Junior Member
Posts: 8
Karma: 10
Join Date: Apr 2014
Device: Kobo Aura HD
|
Thanks chaley, you made my day!
I took it a step forward to create a hierarchy date format with this code: Code:
program: list_split(list_re(field('tags'), ',', '\d{4}-\d{2}-\d{2}', '') , '-' , 'vars'); strcat(vars_0,'.',vars_1,'.',vars_2) It may not be the nicest code but it works! |
03-15-2021, 12:41 PM | #4 | |
Grand Sorcerer
Posts: 11,942
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Another quite similar way to do it would be to use the replacement pattern in list_re: Code:
program: list_re(field('tags'), ',', '(\d{4})-(\d{2})-(\d{2})', '\1.\2.\3') |
|
03-15-2021, 02:30 PM | #5 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Apr 2014
Device: Kobo Aura HD
|
Quote:
I'm not quite familiar with regular expressions but this one i do understand and i like it! |
|
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom Genre Hierarchical Column to tags | jjquin | Library Management | 5 | 03-02-2018 12:25 AM |
How can I boolean OR several tags into one custom column? | bmix | Library Management | 3 | 01-09-2015 03:57 AM |
Download tags to a custom column | atjnjk | Library Management | 8 | 01-18-2012 08:02 AM |
Help with template for custom column from tags | africalass | Library Management | 2 | 07-16-2011 11:47 AM |