Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-15-2016, 05:38 PM   #1
racergirl76
Junior Member
racergirl76 began at the beginning.
 
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.
racergirl76 is offline   Reply With Quote
Old 02-15-2016, 06:09 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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:
Originally Posted by racergirl76 View Post
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.
Use the Search and replace tool of the bulk metadata edit against only those books with the : REGEX MODE

search field: title
search for (.+?)\:(.+?)
Destination will be done in 2 passes
destination Pass1: #maintitle
replace with: \1

destination Pass2: #subtitle
replace with: \2
theducks is offline   Reply With Quote
Advert
Old 02-15-2016, 08:22 PM   #3
racergirl76
Junior Member
racergirl76 began at the beginning.
 
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
racergirl76 is offline   Reply With Quote
Old 02-16-2016, 02:13 AM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
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'),
    ':.*',
    ''
)
Alternatively, "cheat" by using list_item() and pretending it is a ":"-separated list:
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...
eschwartz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 05:45 PM.


MobileRead.com is a privately owned, operated and funded community.