![]() |
#1 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Feb 2016
Device: Nexus 7
|
Help with RegEx to parse title with colon
I've been combing these forums for a week looking for a solution and am now admitting defeat.
I stongly prefer the Title field contain the full (long) title of a book: "Maintitle of Book: Subtitle aka Strapline" For more effencient use of the title contents for writing to disc/saving, templates, and for plugboards, I need to parse the title into two userdefined columns "#maintitle" & "#subtitle" So, I tried using the custom column feature, BUT the colon ":" is part of the regex language and my non-existant regex skills can't figure out how to tell it to 1. Take everything before the ':' and copy to #maintitle 2. Take everything after the ': ' and copy to #subtitle Workarounds such as manually separating the subtitle into comments or another column promotes inconsistency and incompleteness that doesn't work for me. Any help is greatly appreciated, assume I know nothing about Regex. Reading the tutorials and absorbing them are two different things. |
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
search field: title search for (.+?)\:(.+?) Destination will be done in 2 passes destination Pass1: #maintitle replace with: \1 destination Pass2: #subtitle replace with: \2 |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Feb 2016
Device: Nexus 7
|
Thank you, and that does work for text based columns. I had seen a similar solution in post:
https://www.mobileread.com/forums/sho...d.php?t=265061 I'm trying to make it more automated by using the 'column built from other columns' feature. What I was hoping for was to input a template into the make column from other columns for #maintitle(no colon) and #subtitle. Then have Calibre automatically save the book based on a template using the truncated #maintitle column as part of the folder name & file name. I tried several templates for the custom column but don't know what I'm doing. such as #maintitle = contains(field('title')([^:]*)) #subtitle = contains(field('title')([^:]*)re(field('title') somewhere in these forums someone said to split the title into two columns, which we have achieved. But that means I have to manually run that search & replace, and then resave the books to the library based on another template and action. Thank you for your assistance |
![]() |
![]() |
![]() |
#4 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
This will get you the first portion (before the ":")
Code:
program: re( field('title'), ':.*', '' ) Code:
program: list_item( field('title'), 0, ':' ) Personally, I think this is exactly what custom columns named "#subtitle" are for, but you are the boss... |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
RegEx Function: Title Case | phossler | Editor | 29 | 07-04-2020 10:52 AM |
Metadata Parse Reverses Title/Author Academic Texts | johnelle | Library Management | 2 | 08-21-2015 09:54 AM |
Sigil Regex Title case | jcambaya | Sigil | 3 | 06-24-2015 04:47 PM |
Colon in title turns into an underscore on Kindle menu | Connor Carroll | Library Management | 7 | 12-23-2013 10:45 PM |
Can't extract article title in parse index | hiperlink | Recipes | 19 | 01-18-2011 11:00 AM |