|
|
#1 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
Hi All,
I'm hoping a calibre regex guru can help me out with this. I have failed, and even AI couldn't help me. Here's a filename example: A. J. Author, Author Two - This Is the Title (2020) [1234567890123].epub The published date and isbn are independently optional and potentially not in the filename. Here's the closest i got, which only works if the optional items are present: (?P<author>.*?) - (?P<title>.*?) \((?P<published>\d{4})\) \[(?P<isbn>.*?)\] The closest I got with AI was one where it would work if both optional items are present, or if only the isbn. if there is neither or only the year, it returns the entire filename minus extension as the title with no other information other than "unknown" for the author(s). Any help for a regex that works for all four cases would be greatly appreciated! |
|
|
|
|
|
#2 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 23
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
|
Why would you need to use regex? You said the AI couldn't help you, but that was because you asked it to provide you with a straight RegEx to try to catch all. Use the AI to read the book and pull the author(s) and title out for you, with the temperature turned to 0, and you will get the answer correct every time..
It saves messing around with Regex and makes life easier
Last edited by mitsie; 02-11-2026 at 04:17 PM. |
|
|
|
|
|
#3 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,341
Karma: 30621608
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
|
|
|
|
|
#4 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 23
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
|
True, hitting a screw with the back of a power drill isn't the correct way to use that tool, but it might get the job done in a sloppy and inaccurate fashion.. It's the people who learn to turn the power drill around and use the trigger that get better results from the tool..
|
|
|
|
|
|
#5 | |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 50,294
Karma: 178402650
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
When I use regex101.com, for calibre, I select Python and for Sigil, I select PCRE2. |
|
|
|
|
|
|
#6 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
I appreciate the suggestions, and I did attempt to formulate a regex myself, but apparently there are some features of python regex that are not found in calibre's implementation. I'll run some through the regex helper, but I'm not confident.
|
|
|
|
|
|
#7 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
Well, I came up with this one that works perfectly fine on regex101, using the python engine:
(?P<author>[^-]+) - (?P<title>[^(\[]+)(?: \((?P<year>\d{4})\))?(?: \[(?P<isbn>[^\]]+)\])? Doesn't work in calibre however. |
|
|
|
|
|
#8 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,512
Karma: 62503986
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Calibre has no field named Year or ISBN
published? identifiers:isbn? |
|
|
|
|
|
#9 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
You're absolutely right about the year, I don't know how I overlooked that. It does have a (?P<isbn>) in Calibre, however. Thanks!
Last edited by CoreyEMTP; 02-13-2026 at 05:50 PM. |
|
|
|
|
|
#10 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,512
Karma: 62503986
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
|
|
|
|
|
#11 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
For those curious or who have a similar file layout, here's the regex that finally worked:
Code:
^(?P<author>.+?)\s-\s(?P<title>(?:(?!\s[\(\[]).)+)(?:\s\((?P<published>\d{4})\))?(?:\s\[(?P<isbn>\d{10,13})\])?$
Last edited by CoreyEMTP; 02-13-2026 at 06:19 PM. Reason: Wrong layout |
|
|
|
|
|
#12 | |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,512
Karma: 62503986
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
|
|
|
|
|
|
|
#13 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 50,294
Karma: 178402650
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
AFAIR, ISBNs are part of the identifiers table now.
|
|
|
|
|
|
#14 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Feb 2026
Device: Kobo
|
That I don't know, but it does have the item available under the specified settings. The test box reads and displays the parts of the filename in their respective fields, including ISBN.
|
|
|
|
|
|
#15 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,512
Karma: 62503986
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
test box?
Do you mean in the MDE or details section? |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regex for importing books with comment | Widukind | Library Management | 5 | 02-12-2021 06:13 AM |
| Adding Books - Filename Regex Management | Paulie_D | Library Management | 4 | 05-10-2015 02:03 PM |
| Adding books - filename RegEx author FN (initials) LN | Rob557 | Library Management | 8 | 10-16-2014 05:53 PM |
| regex for filename with muliple dots? (adding books) | kite | Library Management | 5 | 09-28-2014 10:09 AM |
| Need a regex for importing books | flinkdeldinky | Calibre | 31 | 10-29-2011 09:31 AM |