Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-14-2014, 10:07 AM   #1
wladdy
Enthusiast
wladdy began at the beginning.
 
Posts: 28
Karma: 10
Join Date: Oct 2010
Device: iPad / Kindle DX
Search and replace returns entire field when no match is found

A bunch of books titles contain either the title followd by the publication year (eg: "The shining (1977)") or the title by itself (eg: "Carrie").

To isolate all years and move them into pubdate, I search for the following regex in the title field (let's assume no parenthesis in the book titles per se) :

.* \((\d{4})\)

Although \1 returns "1977" for the first example, it also returns "Carrie" for the second, despite there being no match.

Granted, I can work around this by this first selecting the books whose title contains parentheses. However, I would like to understand better how Calibre's search and replace feature works with regexes.

Therefore, my question is: can I tell Calibre to return nothing instead of everything when no match is found.

Thank you!
wladdy is offline   Reply With Quote
Old 02-14-2014, 01:26 PM   #2
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
advanced search - "what kind of match to use"- what do you have that set to?

if I search my entire library - with that field dropdown option set to Regular Expresssion:.... and with your find regex, i.e. with this in the title box
.* \((\d{4})\)
it finds only books with a four digit number in the title
8 hits out of nearly 2000 titles.
strangely, none of my 8 hits have brackets around the numbers, so that regex is not quote right yet, but I don't get what you are describing
For me, that code it is finding titles like
The War Within: A Secret White House History 2006-2008
but as per my knowledge of regex, I should find no matches, either the calibre version is a different dialect or the escape-bracket bits are being ignored ?

I also observe the when any advanced search query is loaded into the search bar, a tilde ~ is added to the search term. that's another bit of regex-foo that I don't get

Last edited by cybmole; 02-14-2014 at 03:42 PM.
cybmole is offline   Reply With Quote
Advert
Old 02-16-2014, 01:51 AM   #3
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
can I have a 2nd opinion on my previous post tests please. The OP seems to have lost interest but I am still puzzled re the brackets.
cybmole is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace: want to remove value that matches another field einniv Library Management 0 07-25-2013 08:18 PM
Using Search & Replace with Identifiers field BookJunkieLI Calibre 6 11-13-2012 01:20 PM
Search/Replace from Title Field to Pubdate TMSxMR Library Management 5 08-06-2012 03:40 AM
Replace field with match or empty string? charlweed Library Management 2 03-29-2012 12:44 AM
Metadata Search & Replace - when it doesn't match Aldebaranian Library Management 4 09-28-2011 11:35 AM


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


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