04-14-2012, 06:41 AM | #1 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Calling Expression experts
I'm trying to get the expression to ignore anything before the author's name and, perhaps anything after the Title but this is as far as I got.
I'm reading the tutorial http://manual.calibre-ebook.com/regexp.html but not getting far. Thanks |
04-14-2012, 11:07 PM | #2 |
Wizard
Posts: 4,812
Karma: 26912940
Join Date: Apr 2010
Device: sony PRS-T1 and T3, Kobo Mini and Aura HD, Tablet
|
If you have a lot of books like that you could use search and replace with
\d\d-\d\d- \d\d\d\d Probably an expression on import would work but I am wimpy in that area. Helen |
Advert | |
|
04-15-2012, 05:19 AM | #3 |
Guru
Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
As long as the filesname follow your example, here's a quick solution.
Code:
\d+-\d+-(?P<author>.+) - (?P<title>.+) \d+ Code:
\d+-\d+-(?P<author>.+) - (?P<title>.+) (?P<published>\d+) |
04-15-2012, 08:49 AM | #4 | ||
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Quote:
Quote:
Your "d+" expression now explains better what the tutorial says about "\d is equivalent to [0-9]" and also helps me understand the expression better. |
||
04-15-2012, 11:28 AM | #5 |
Well trained by Cats
Posts: 30,421
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Decoding the above:
anything not inside a ( ) pair is not captured and is discarded. The term does need to match what is there for this to work (at all ) |
Advert | |
|
04-15-2012, 12:08 PM | #6 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Thank you - that helps even more.
It's great to learn step by step using examples (tutorials are excellent but sometimes, this is better) I'm very graphical and all your replies are really appreciated. |
04-17-2012, 03:54 AM | #7 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Drag-n-drop
Using a test file and an expression with the above information and everything worked well. (image 1)
But if I drag-n-drop it doesn't work (image 2) Am I doing something wrong. Thanks |
04-17-2012, 06:37 AM | #8 |
Guru
Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
Remove the [] from the expression, or change to ().
They mean that you want to use inclusive (or exclusive) characters, or a range of characters e.g. [a-o] means any lower case letter from a to o (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) [a-oxz] means any lower case letter from a to o or x or z Last edited by Perkin; 04-17-2012 at 06:43 AM. |
04-17-2012, 07:48 AM | #9 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Thank you Perkin.
Again, it worked in test mode but not in drag-n-drop as can be seen. Could it be because I'm using d-n-d???? Thanks |
04-17-2012, 08:19 AM | #10 |
Guru
Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
Just use .+ to match all the garbage after the ' - ' seperator
Code:
(?P<title>.+) - .+ |
04-17-2012, 10:08 AM | #11 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Thank you again.
This does NOT work for me. Could (or has) anyone actually tried it out by using drag-n-drop? Is it a "bug" (I hate saying that, sorry) or is it a limitation and therefore not available using drag-n-drop. Obviously it is reading the metadata from the mp3 file because the author's name is NOT part of the file name. |
04-17-2012, 10:37 AM | #12 |
Calibre Plugins Developer
Posts: 4,678
Karma: 2162246
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Drag and drop is no different to using add. It will use your regular expression for a text file. However I notice you still had "Get metadata from file contents" ticked in a screenshot above, so if you drag/dropped an epub or mobi for instance it is going to use title/author metadata from inside the file, NOT evaluate your regex. If relying on filenames/regex is how you want to do your imports, then untick that other option.
Apologies if I missed it but I haven't seen you post the actual filename of the file you are drag/dropping. I see lots of screenshots of regexes and the result, but not what the actual name of the file is. If your "plan" for the regex was based on a flawed assumption then everyone's suggestions to tweak it aren't going to do any good... |
04-17-2012, 10:53 AM | #13 |
Chief Inspector Gamache
Posts: 123
Karma: 12
Join Date: May 2010
Location: Canada eh!
Device: Viewsonic
|
Thanks KiwiDude
That worked great - I knew I was doing something wrong. It was the actual file name with the exception that it was an ".mp3" rather than a ".txt" Testing would not allow me to use ".mp3" as an extension. Thank you everyone else with your help and patience - I learnt a lot from your expression examples. |
Tags |
expresions |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calling all font and code experts | ltr | Kobo Reader | 7 | 12-09-2011 08:28 PM |
CSS Experts | Japes | Sony Reader | 8 | 06-24-2011 09:07 AM |
PRS-600 Font experts . help please | jacko5 | Sony Reader | 7 | 03-15-2011 12:39 PM |
Hello experts, | Vijay | Introduce Yourself | 10 | 11-22-2010 12:29 PM |
Question to Experts | srinivasvaradar | Sony Reader | 3 | 09-30-2007 04:05 PM |